A task in WSO2 ESB allows you to run a piece of code triggered by a timer. WSO2 ESB is already bundled with a task, which can be used to inject a message to ESB given by the configuration at a scheduled interval (5000 ms). To activate the build-in task, you should add it to the "Tasks" list.
A user can also write his own task. It will be a custom developed Java class which implements the org.apache.synapse.startup.Task
interface. This interface defines a single method named execute ()
. For example, you can create a task which will read a text file at a specified location and place orders for stocks that are given in the text file. To learn more information on how to write a custom task, see Writing Tasks and Writing Tasks Sample.
Tasks can be scheduled on the ESB to execute periodically. Having deployed a task implementation into the ESB runtime, you can use the ESB management console to schedule various instances of the task. It is possible to schedule a task by specifying the number of times it needs to run along with the frequency or you can use the cron syntax.
The process of task application.
WSO2 ESB also provides a user friendly interface to edit and delete tasks.