This is the latest release in the 6.x.x family. For EI 7.0.0, click here.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: updated the task source

...

  1. In the Form View of the InjectXMLTask.xml file, click the Task Implementation Properties button.
  2. Select XML as the parameter type of the message parameter and enter <abc>This is a scheduled task of the default implementation.</abc> as the XML message in the Value/Expression field.
    Also, specify Sequence as the parameter type of the injectTo parameter and fill in the sequence name, which was created above (InjectXMLSequence.xml).
    Click OK to create the task property.


    Expand
    titleMore information on the above properties
    Parameter NameDescription
    message

    Specify the body of the request that should be sent when the task is executed.

    Tip

    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. 

    soapActionThis is the SOAP action to use when sending the message to the endpoint. 
    to

    If the task should send the message directly to the endpoint through the main sequence, the endpoint address should be specified. For example, if the address of the endpoint is http://localhost:9000/services/SimpleStockQuoteService, the Synapse configuration of the scheduled task will be as follows:

    Code Block
    <task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="CheckPrice">        <property name="to" value="http://localhost:9000/services/SimpleStockQuoteService"/>
            <property name="soapAction" value="urn:getQuote"/>
            <property name="message">
                <m0:getQuote xmlns:m0="http://services.samples" xmlns="http://ws.apache.org/ns/synapse">
                    <m0:request>
                        <m0:symbol>IBM</m0:symbol>
                    </m0:request>
                </m0:getQuote>
            </property>
            <trigger interval="5"/>
        </task>
    injectToIf the task is not sending the message directly to the endpoint (through the main sequence), it should be injected to proxy service or a sequence. Specify sequence, or proxy.
    sequenceName

    If the task should inject the message to a sequence (injectTo parameter is sequence), enter the name of the sequence. For example, if the name of the sequence is 'SampleSequence', the synapse configuration of the scheduled task will be as follows:

    Code Block
    <task name="SampleInjectToSequenceTask"
             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="injectTo"
                    value="sequence"/>
    
          <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="sequenceName"
                    value="SampleSequence"/>
    
       </task>
    proxyName

    If the task should inject the message to a proxy service (injectTo parameter is proxy), enter the name of the proxy service. For example, if the name of the proxy service is 'SampleProxy', the synapse configuration of the scheduled task will be as follows:

    Code Block
     <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>
    Info

    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.

    Localtab Group
    Localtab
    titleTask Configuration
    Code Block
    <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="injectTo"
                    value="proxy"/>
          <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="message">
             <request xmlns="">
                <location>
                   <city>London</city>
                   <country>UK</country>
                </location>
             </request>
          </property>
          <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks"
                    name="proxyName"
                    value="SampleProxy"/>
       </task>
    Localtab
    titleProxy Service
    Code Block
    <proxy name="SampleProxy"
              transports="https http"
              startOnLoad="true"
              trace="disable">
          <description/>
          <target>
             <inSequence>
                <property name="uri.var.city" expression="//request/location/city"/>
                <property name="uri.var.cc" expression="//request/location/country"/>
                <log>
                   <property name="Which city?" expression="get-property('uri.var.city')"/>
                   <property name="Which country?" expression="get-property('uri.var.cc')"/>
                </log>
                <send>
                   <endpoint name="EP">
                      <http method="get"
                            uri-template="http://api.openweathermap.org/data/2.5/weather?q={uri.var.city},{uri.var.cc}"/>
                   </endpoint>
                </send>
             </inSequence>
             <outSequence>
                <log level="full"/>
                <drop/>
             </outSequence>
          </target>
       </proxy>
    The below

    Below is the complete source configuration of the Scheduled Task (i.e., the InjectXMLTask.xml file).


    Expand
    titleConfiguration of the Scheduled Task
    Expand
    titleConfiguration of the Scheduled Task
    Code Block
    languagexml
    <?xml version="1.0" encoding="UTF-8"?>
    <task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="InjectXMLTask" xmlns="http://ws.apache.org/ns/synapse">
        <trigger interval="5"/>
        <property name="sequenceName" value="InjectXMLSequence" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
        <property name="injectTo" value="sequence" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/>
        <property name="message" xmlns:task="http://www.wso2.org/products/wso2commons/tasks">
            <abc xmlns="">This is a scheduled task of the default implementation.</abc>
        </property>
    </task>



Deploying the Task

  1. Open the pom.xml file of the Composite Application Project and select the artifacts that need to be deployed.
  2. Start the ESB profile by adding the ScheduleDefaultTaskCompositeApplication. For instructions, see Running the ESB profile via WSO2 Integration Studio.

...