This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

You can create a new scheduled task or to import an existing scheduled task from the file system using WSO2 EI tooling. 

You need to have WSO2 EI tooling installed to create a new task or to import an existing task via tooling. For instructions on installing WSO2 EI tooling, see Installing Enterprise Integrator Tooling.

Creating a new scheduled task

Follow these steps to create a new scheduled task. Alternatively, you can import an existing scheduled task.

  1. In Eclipse, click the Developer Studio menu and then click Open Dashboard. This opens the Developer Studio Dashboard.
  2. Click Scheduled Task on the Developer Studio Dashboard.
  3. Select Create a New Scheduled Task Artifact and click Next.
  4. The New Scheduled Task page appears. Enter the required details into the fields.

    ParameterDescription
    Task NameName of a scheduled task.
    Task GroupThe group name to grouping tasks. The group name synapse.simple.quartz belongs to the ESB profile - 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 ImplementationThe implementation class of the task. To use the default task implementation that is available with the the ESB profile (and therefore can be used without downloading any third-party libraries or custom JARs), specify  org.apache.synapse.startup.tasks.MessageInjector. This class simply injects a specified message into the Synapse environment at WSO2 EI startup. For more information on writing custom task implementations, see Writing Tasks.
    Trigger TypeTrigger type for the task. This can be selected as either "Simple" or "Cron."
    • Simple Trigger- Defined by specifying a count and an interval, implying that the task will run a count number of times at specified intervals.
      • Count- The number of times the task will be executed.
      • Interval - The interval between consecutive executions of a task.
    • Cron Trigger - Defined using a cron expression.
    Pinned Servers

    The list of ESB server nodes that will run the task. You can specify the IP addresses of the required nodes. 

    This setting can be used if you want the task to run on a selected set of nodes in an ESB cluster. Note that the task will only run on one of the nodes at a time. It will failover to another node, only if the first node fails.

    Pinned servers will override the default task handling behavior defined at server-level (for this particular task). However, if rule-based task handling is specified at server-level, you need to ensure that the same server nodes you specify as pinned servers for the task are also specified for the task handling rule at server-level.

    Following are examples of configuring some common use cases.

    To run every 5 seconds continuously:

    <task name="CheckPrice" class="org.wso2.esb.tutorial.tasks.PlaceStockOrderTask">
    <trigger interval="5"/>
    </task>
    

    To run every 5 seconds for 10 times: 

    <task name="CheckPrice" class="org.wso2.esb.tutorial.tasks.PlaceStockOrderTask">
    <trigger interval="5" count="10"/>
    </task>
    

    You can also give cron-style values. To run daily at 1:30 AM:

    <task name="CheckPrice" class="org.wso2.esb.tutorial.tasks.PlaceStockOrderTask">
    <trigger cron="0 30 1 * * ?"/>
    </task>
    

    To run only once after WSO2 EI starts:

    <task name="CheckPrice" class="org.wso2.esb.tutorial.tasks.PlaceStockOrderTask">
    <trigger once="true"/>
    </task>
  5. Do one of the following:
    • To save the task in an existing ESB Config project in your workspace, click Browse and select that project.
    • To save the task in a new ESB Config project, click Create new ESB Project and create the new project.
  6. Click Finish. The scheduled task is created in the src/main/synapse-config/tasks folder under the ESB Config project you specified. 
  7. You can open the file from the project explorer to start entering properties.
  8. Click Task Implementation Properties to start using the following parameters and values:

    Parameter Name
    The unique name of the task property. The org.apache.synapse.startup.tasks.MessageInjector implementation takes the following properties: 
    • format - defines the format of the message similar to Address Endpoint formats: soap11, soap12, pox, get
    • message  - you can provide an XML or literal value depending on message format.

      Note

      When you add a scheduled task, it is mandatory to provide a value for the message property. Therefore, even If you do not want to send a message body, you have to provide an empty payload as the value to avoid an exception being thrown.

    • soapAction - specify the SOAP Action to use when sending the message to the endpoint. 
    • to - specify the endpoint address. 
    • injectTo - specify whether to inject a message to a proxy service or sequence. This field takes values 'sequence' or 'proxy' and 'main' to inject to main sequence. 
    • proxyName - if injectTo contains 'proxy' then the name of the proxy to inject the message to is specified here. 
    • sequenceName - if injectTo contains 'sequence' then the name of the sequence to inject the message to is specified here.
    Parameter Type
    • XML
    • Literal

    Value/ExpressionThe value corresponding to the the Parameter and Type that is used.
  9. Click OK to finish updating the properties.

Importing a scheduled task

Follow these steps to import an existing scheduled task into an ESB Config project. Alternatively, you can create a new scheduled task.

  1. In Eclipse, click the Developer Studio menu and then click Open Dashboard. This opens the Developer Studio Dashboard.
  2. Click Scheduled Task on the Developer Studio Dashboard.
  3. Select Import Scheduled Task Artifact and click Next.
  4. Specify the XML file that defines the scheduled task by typing its full pathname or clicking Browse and navigating to the file.
  5. In the Save Task In field, specify an existing ESB Config project in your workspace where you want to save the task, or click Create new ESB Project to create a new ESB Config project and save the task configuration there.
  6. If there are multiple tasks definitions in the file, click Create ESB Artifacts, and then select the tasks you want to import.
  7. Click Finish. The tasks you selected are created in the subfolders of the src/main/synapse-config/tasks folder under the ESB Config project you specified, and the first task appears in the editor.
  • No labels