web.inbound.docs.userguide.html Maven / Gradle / Ivy
Scheduled Tasks - User Guide
Scheduled Tasks
A task is a custom developed Java class which implements the org.apache.synapse.startup.Task
interface. This interface defines a single method named 'execute'. Tasks can be scheduled on
the ESB to execute periodically. If required a task can be configured to run only a limited
number of times.
Before a task can be scheduled on the ESB it has to be compiled and packaged into a jar file.
This jar file should then be placed in the repository/components/lib directory of the ESB. It
is then required to restart the ESB for the jar containing the task implementation to be picked
up by the server runtime. An OSGi bundle containing the task implementation will be created
automatically and it will be deployed in the server.
Having deployed a task implementation into the ESB runtime, one 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.
Scheduling a Task
-
In the navigator, under Manage > Service Bus, click Scheduled Tasks. The Scheduled Tasks page
appears.
Figure 1. Scheduled Tasks Panel
-
Click Add Task.
-
Enter the required details and click Schedule. Field Descriptions
Figure 2. New Scheduled Task Configuration Panel
Field Descriptions
Scheduled
Tasks
Field Name
Description
Task Name
Name of the scheduled task
Task Group
The Group name to grouping tasks. The group name
synapse.simple.quartz groups the tasks belongs to ESB -
Synapse. All available groups are displayed as a drop down menu.If
there are tasks belong to some other domains - for example WSO2 Mashups
tasks, then those will be shown here as a separate group names.
Task Implementation
The implementation class of the task.There is a default task
implementation which is shipped with ESB. It is
org.apache.synapse.startup.tasks.MessageInjector which just injects a
message specified into Synapse environment. ESB sample 300 demonstrates
this.
Trigger Type
Trigger type for the task. This can be either Simple or Cron. A
simple trigger is defined by specifying a 'count' and an 'interval',
implying that the task will run a 'count' number of times at specified
intervals. A cron trigger is defined using a cron expression.
Count
The number of times the task will be executed.
Interval
The interval between consecutive executions of a task
Pinned servers
Provide a list of ESB server names where this task should be started
for the Pinned server value.
An Example
This example only shows how to specify the task implementation class and specify
properties required by that task implementaion.
Task implementation class used in this example is named
org.apache.synapse.startup.tasks.MessageInjector. This class
is available in the standard WSO2 ESB distribution and hence can be used out of
the box without deploying any other third party libraries or custom jars. Figure 3
shows the page in the management console after the Load Class button is clicked. It
shows the instance properties of MessageInjector task implementation.
(Refer ESB sample 300 for more information)
Figure 3 . A Task Example