Task is a one of the methods of automatic driving the mediation in the ESB. It is an implementation of ESB Startup which allows adding tasks, it should run at ESB startup. Task is a Startup and it is based on Quartz, an open source job scheduling system. Task can be used to create schedules:
- Simple schedules - May be a schedule to run a task periodically.
- Complex schedules - May be a schedule to run at specific time in the future. It can be specified using
A task is created and scheduled to run at specified time intervals or as specified by the
cron expression. The Task class specifies the actual task implementation class (which must implement
org.apache.synapse.task.Taskinterface) to be executed at the specified interval/s, and name specifies of an identifier for the scheduled task.
The current ESB has only one implementation -
org.apache.synapse.startup.tasks.MessageInjector. It can be used to inject messages at ESB startup.
Fields in the task class can be set using properties provided as string literals or as XML fragments.
For example, if the task implementation class has a field named "version" with a corresponding setter method, the configuration value which will be assigned to this field before running the task can be specified using a property with the name "version."
There are three different trigger mechanisms to schedule tasks:
- A simple trigger - Is specified by "count" and "interval", implying that the task will run a "count" number of times at specified intervals.
- A cron trigger - May be specified using a
- A one-time trigger - Is specified using the
onceattribute as true in the definition and could be specified as true in this case this task will be executed only once just after the initialization of ESB.
You can give a list of Synapse server names where this task should be started using
A custom Task can be developed by writing a custom
Java class that implements the
org.apache.synapse.task.Task interface. Task interface is shown bellow.