Scheduled Tasks - User Guide

Scheduled Tasks

A Task is a custom Java class that implements the org.apache.synapse.startup. Task interface that defines a single public void execute() method. These tasks can be scheduled and managed using the WSO2 Enterprise Service Bus (ESB). Tasks can be scheduled in a cron format or a simple format. >A task can be specified as a one-time task, if required, and can be used to trigger a callout or send a message to the WSO2 ESB

Scheduling a Task

  1. In the navigator, under Configure, click Scheduled Tasks. The Scheduled Tasks page appears.
  2. Click Add Task. Add New Scheduled TaskFigure 1. Scheduled Tasks Panel
  3. Enter the required details and click Schedule. Field Descriptions

Scheduled Task configuration panel

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 use Task Implementation Class and fill properties of that Task Implementaion. For this example, server need to be a ESB instance.

Task Implementation Class is org.apache.synapse.startup.tasks.MessageInjector. Figure 3 shows the UI snapshot that appear after clicking the load class button. It shows the instance properties of MessageInjector.This is corresponding to the ESB sample 300.

Task Example

Figure 3 . An Task Example

For more information please refer to the WSO2 library