Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Tip

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.

Anchor
create
create
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. Leave the first option selected and Select Create a New Scheduled Task Artifact and click Next.
  4. Type a unique name for this scheduled task and specify the group, implementation class, and other options. For more information, see Adding and Scheduling Tasks.
  5. 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. 

    Info

    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.

    Anchor
    interval
    interval
    To run every 5 seconds continuously:

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

    Anchor
    specified number of times
    specified number of times
    To run every 5 seconds for 10 times: 

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

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

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

    Anchor
    once
    once
    To run only once after WSO2 EI starts:

    Code Block
    <task name="CheckPrice" class="org.wso2.esb.tutorial.tasks.PlaceStockOrderTask">
    <trigger once="true"/>
    </task>
  6. 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.
  7. Click Finish. The scheduled task is created in the src/main/synapse-config/tasks folder under the ESB Config project you specified. When prompted, you  
  8. You can open the file in the editor, or you can right-click the task in the project explorer and click Open With > ESB Editor. Click its icon in the editor to view its from the project explorer to start entering properties.
  9. 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
      titleNote

      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.
  10. Click OK to finish updating the properties.

Anchor
import
import
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.

...