<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
  ~
  ~  WSO2 Inc. licenses this file to you under the Apache License,
  ~  Version 2.0 (the "License"); you may not use this file except
  ~  in compliance with the License.
  ~  You may obtain a copy of the License at
  ~
  ~    http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing,
  ~  software distributed under the License is distributed on an
  ~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~  KIND, either express or implied.  See the License for the
  ~  specific language governing permissions and limitations
  ~  under the License.
  -->

<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
  <title>WSO2 ESB - Tasks Samples </title>
</head>

<body>
<h1>Running the Tasks samples with WSO2 Enterprise Service Bus (ESB) </h1>

    <h2><a name="Sample300">Sample 300: Introduction to tasks with simple
    trigger</a> </h2>
    <pre xml:space="preserve">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;

        &lt;task class="org.apache.synapse.startup.tasks.MessageInjector" name="CheckPrice"&gt;
            &lt;property name="to" value="http://localhost:9000/services/SimpleStockQuoteService"/&gt;
            &lt;property name="soapAction" value="urn:getQuote"/&gt;
            &lt;property name="message"&gt;
                &lt;m0:getQuote xmlns:m0="http://services.samples"&gt;
                    &lt;m0:request&gt;
                        &lt;m0:symbol&gt;IBM&lt;/m0:symbol&gt;
                    &lt;/m0:request&gt;
                &lt;/m0:getQuote&gt;
            &lt;/property&gt;
            &lt;trigger interval="5"/&gt;
        &lt;/task&gt;

        &lt;in&gt;
            &lt;send/&gt;
        &lt;/in&gt;
        &lt;out&gt;
            &lt;log level="custom"&gt;
                &lt;property name="Stock_Quote_on" expression="//ns:return/ax21:lastTradeTimestamp/child::text()" xmlns:ax21="http://services.samples/xsd" xmlns:ns="http://services.samples"/&gt;
                &lt;property name="For_the_organization" expression="//ns:return/ax21:name/child::text()" xmlns:ax21="http://services.samples/xsd" xmlns:ns="http://services.samples"/&gt;
                &lt;property name="Last_Value" expression="//ns:return/ax21:last/child::text()" xmlns:ax21="http://services.samples/xsd" xmlns:ns="http://services.samples"/&gt;
            &lt;/log&gt;
        &lt;/out&gt;

    &lt;/definitions&gt;</pre>

    <p><strong>Objective: Introduce the concept of tasks and how simple trigger
    works</strong> </p>

    <p><strong>Prerequisites:</strong><br />
    You will need access to build the SimpleStockQuoteService as mentioned in the
    above and start the sample axis2 server before staring ESB. </p>

    <p>When ever ESB gets started with this configuration (i.e. ./wso2esb-samples -sn 300), 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. </p>

    <p>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 into the ESB environment. </p>

</body>
</html>
