Using the WSO2 Data Services Server, a task can be scheduled to execute periodically and also only a limited number of times. Follow the steps below to schedule a task.
1. Log on to the Data Services Server Management Console and select "Data Services -> Scheduled Tasks" in the "Main" menu.
2. The "Scheduled Tasks" page opens. Click the "Add New Task" link.
3. Fill the required information.
Tasks can be configured to invoke a data-service operation or to use a custom java class which implements the "org.wso2.carbon.dataservices.task.DataTask" interface. The following set of properties should be defined in order to successfully create a task.
- Task Name : Name of the scheduled task.
- Task Repeat Count : Number of cycles to be executed. If you enter 0, the task will execute once. If you enter 1, the task will execute twice and so on.
- Task Interval : Time gap between two consecutive task executions.
- Start Time : Starting time of the scheduled task. If this is not given, the task will start at the moment the it is scheduled.
Parameters required to define a task that uses a data-service operation
- Data Service Name : Name of the relevant data service.
- Operation Name : Data service operation to be executed from the task.
Parameters required to define a task that uses a custom java class
- Data Service Task Class : Name of the java class which has implemented "org.wso2.carbon.dataservices.task.DataTask" interface. The definition of the interface is follows:
The following code snippet shows a sample DataTask implemenation:
4. After configuring the task with appropriate values, click the "Schedule" button to complete.