This documentation is for WSO2 ESB version 4.0.2. View documentation for the latest release.

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

Version 1 Next »

Introduction to Tasks with Simple Trigger

<definitions xmlns="http://ws.apache.org/ns/synapse">
<task name="CheckPrice">
        <property name="to" value="http://localhost:9000/soap/SimpleStockQuoteService"/>
        <property name="soapAction" value="urn:getQuote"/>
        <property name="message">
            <m0:getQuote xmlns:m0="http://services.samples/xsd">
                <m0:request>
                    <m0:symbol>IBM</m0:symbol>
                </m0:request>
            </m0:getQuote>
        </property>
        <trigger interval="5000"/>
    </task>

    <in>
        <send/>
    </in>
    <out>
        <log level="custom">
            <property name="Stock Quote on" expression="//ns:return/ns:lastTradeTimestamp/child::text()" xmlns:ns="http://services.samples/xsd"/>
            <property name="For the organization" expression="//ns:return/ns:name/child::text()" xmlns:ns="http://services.samples/xsd"/>
            <property name="Last Value" expression="//ns:return/ns:last/child::text()" xmlns:ns="http://services.samples/xsd"/>
        </log>
    </out>

</definitions>*

Objective:

Introduce the concept of tasks and how simple trigger works.

Prerequisites:

You will need access to build the SimpleStockQuoteService as mentioned above and start the sample axis2 server before staring ESB.

When ever ESB gets started and initialized, this task will run periodically in 5 second intervals. You could limit the number of times that you want to run this task by adding a count attribute with an integer as the value, if the count is not present as in this sample this task will run forever.

One can write his own task class implementing the org.apache.synapse.startup.Task interface and implementing the execute method to do the task. For this particular sample, we have used the MessageInjector, which just injects a message specified in to the ESB environment.

  • No labels