This documentation is for WSO2 Enterprise Service Bus version 4.8.1 . View documentation for the latest release.

All docs This doc

Versions Compared

Key

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

...

Having deployed a task implementation to the ESB runtime (see Writing Tasks), you can use the ESB Management Console to add a task to the "Tasks" list and schedule various instances of the task. You can use either UI configuration  or XML configuration to add and schedule tasks.

...

Anchor
UI configuration
UI configuration

UI Configuration

Follow the instructions below to add and schedule a task in ESB Management Console.

...

9. Click Schedule to apply the settings.

...

Anchor
XML configuration
XML configuration

XML Configuration

Follow the instructions below to add and schedule tasks using XML configuration.

...

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: Anchorcron stylecron style

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

Anchor
once
once

To run only once after ESB starts: Anchoronceonce

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

Anchor
inject
inject

Injecting the message to a named sequence or proxy service 

...

By default, the message is sent to the Main sequence. To send it to a different sequence or to a proxy service, set the injectTo property to sequence or proxy, and then add the sequenceName or proxyName property to specify the name of the sequence or proxy service to use. For example:

...

Code Block
languagehtml/xml
titleInjecting to a proxy service
 <task name="SampleInjectToProxyTask"
         class="org.apache.synapse.startup.tasks.MessageInjector"
         group="synapse.simple.quartz">
      <trigger count="2" interval="5"/>
      <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
         <m0:getQuote xmlns:m0="http://services.samples">
            <m0:request>
               <m0:symbol>IBM</m0:symbol>
            </m0:request>
         </m0:getQuote>
      </property>

      <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"

                name="proxyName"
                value="SampleProxy"/>

      <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
                
                name="injectTo"
                value="proxy"/>

   </task>

 

Anchor
inject
inject

Injecting messages to RESTful Endpoints 

...

In order to use the Message Injector to inject a message to a RESTful endpint, we can specify the injector with the required payload and inject the message to sequence or proxy service as defined above. The sample below shows a RESTful message injection through a ProxyService.

...