This documentation is for WSO2 Data Services Server 3.5.0. View documentation for the latest release.
Scheduling Tasks - Data Services Server 3.5.0 - WSO2 Documentation
Due to a known issue do not use JDK1.8.0_151 with WSO2 products. Use JDK 1.8.0_144 until JDK 1.8.0_162-ea is released.
Skip to end of metadata
Go to start of metadata

Task scheduling is used to invoke a data service operation periodically or for a specified number of times. Read about data services and operations. The scheduling functionality is useful when a specific data service operation scheduled for execution is associated with an event-trigger. When such a scheduled task is run, the event can be automatically fired by evaluating the event trigger criteria. For example, we can schedule a task on getProductQuantity operation and set an event to send an email if the quantity goes down to some level.

Task scheduling functionality is provided by the following feature in the WSO2 feature repository:

Name : Data Service Tasks Feature
Identifier :

The following topics are covered:

Configuring server for task handling

For instructions on how to configure the Task Scheduling component for you server, see the admin guide in the WSO2 Carbon documentation.

Adding Scheduled Tasks

Follow the steps given below to schedule a task.

  1. Log in to the management console of the Data Services Server and select Data Services > Scheduled Tasks in the Main menu.    
  2. The Scheduled Tasks window opens. Click Add New TaskFill the required information.

    You can configure a task to invoke a data service operation or to use a custom Java class that implements the org.wso2.carbon.dataservices.task.DataTask interface. To successfully create a task, provide the following set of properties:

    • 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 as soon as it is scheduled.

    Parameters required for defining 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.

      Note that only data services with HTTP endpoints are available when scheduling tasks to invoke data service operations. Also, you can use only operations with no input parameters when scheduling.

    Parameters required for defining a task that uses a custom java class:

    • Data Service Task Class : Name of the java class that implements org.wso2.carbon.dataservices.task.DataTask interface. The definition of the interface is as follows:

      package org.wso2.carbon.dataservices.task;
       * This interface represents a scheduled data task.
      public interface DataTask 
          void execute(DataTaskContext ctx);

      The following code snippet shows a sample DataTask implementation:

      package samples;
      import java.util.HashMap;
      import java.util.Map;
      import org.wso2.carbon.dataservices.core.DataServiceFault;
      import org.wso2.carbon.dataservices.core.engine.ParamValue;
      import org.wso2.carbon.dataservices.task.DataTask;
      import org.wso2.carbon.dataservices.task.DataTaskContext;
      public class SampleDataTask implements DataTask {    
         public void execute(DataTaskContext ctx) {
             Map<String, ParamValue> params = new HashMap<String, ParamValue>();
             params.put("increment", new ParamValue("1000"));
             params.put("employeeNumber", new ParamValue("1002"));
             try {
                 ctx.invokeOperation("RDBMSSample", "incrementEmployeeSalary", params);
             } catch (DataServiceFault e) {
               // handle exception
  • No labels