How to Schedule Tasks Using a Simple Trigger¶ This example demonstrates the concept of tasks and how a simple trigger works. Here the MessageInjector class is used, which injects a specified message to the WSO2 Integrator: MI environment. You can write your own task class implementing the org.apache.synapse.startup.Task interface and implement the execute method to run the task. Synapse configurations¶ Following are the integration artifacts that we can used to implement this scenario. See the instructions on how to build and run this example. Scheduled triggerMain SequenceEndpoint <?xml version="1.0" encoding="UTF-8"?> <task class="org.apache.synapse.startup.tasks.MessageInjector" group="synapse.simple.quartz" name="CheckPrice" xmlns="http://ws.apache.org/ns/synapse"> <trigger interval="5"/> <property name="soapAction" value="urn:getQuote" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/> <property name="format" value="soap11" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"/> <property name="message" xmlns:task="http://www.wso2.org/products/wso2commons/tasks"> <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="injectTo" value="sequence"/> <property xmlns:task="http://www.wso2.org/products/wso2commons/tasks" name="sequenceName" value="retrieveQuote"/> </task> <?xml version="1.0" encoding="UTF-8"?> <sequence name="retrieveQuote" trace="disable" xmlns="http://ws.apache.org/ns/synapse"> <call> <endpoint key="SimpleStockQuoteService"/> </call> <log level="custom"> <property name="First_Value" expression="//ns:getQuoteResponse/ns:return/ax21:open/child::text()" xmlns:ax21="http://services.samples/xsd" xmlns:ns="http://services.samples"/> <property name="For_the_organization" expression="//ns:getQuoteResponse/ns:return/ax21:name/child::text()" xmlns:ax21="http://services.samples/xsd" xmlns:ns="http://services.samples"/> <property name="Last_Value" expression="//ns:getQuoteResponse/ns:return/ax21:last/child::text()" xmlns:ax21="http://services.samples/xsd" xmlns:ns="http://services.samples"/> </log> <drop /> </sequence> <endpoint name="SimpleStockQuoteService" xmlns="http://ws.apache.org/ns/synapse"> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> Build and run¶ Create the artifacts: Launch Visual Studio Code with the WSO2 Integrator: MI for VS Code extension (MI for VS Code) installed. Info Follow the Install WSO2 Integrator: MI for VS Code documentation for a complete installation guide. Create an integration project. Create the main sequence, endpoint, and a Scheduled trigger with the configurations given above. Deploy the artifacts in your WSO2 Integrator: MI. Set up the back-end service: Download the back-end service. Extract the downloaded zip file. Open a terminal, navigate to the axis2Server/bin/ directory inside the extracted folder. Execute the following command to start the axis2server with the SimpleStockQuote back-end service: On MacOS/LinuxOn Windows sh axis2server.sh axis2server.bat When the WSO2 Integrator: MI is invoked, you will see that the back-end service generates a quote every 5 seconds and that the WSO2 Integrator: MI receives the stock quote response.