This sample introduces the concept of tasks and demonstrates how a simple trigger works. Here the
MessageInjector class is used, which injects a specified message to the ESB 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.
For a list of prerequisites, see Prerequisites to Start the ESB Samples.
Building the sample
The XML configuration for this sample is as follows:
This configuration file
synapse_sample_300.xml is available in the
To build the sample
Build and deploy the back-end service SimpleStockQuoteService. For instructions on deploying sample back-end services, see Deploying sample back-end services.
Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.
Executing the sample
- Start the ESB with the sample 300 configuration. For instructions on starting a sample ESB configuration, see Starting the ESB with a sample configuration.
synapse_sample_300.xml configuration adds a scheduled task to the ESB runtime so that when you start the ESB, this task will run periodically every 5 seconds. You can limit the number of times that you want the task to run by adding a
count attribute with an integer as the
value. If the count is not present as in this sample, the task will run forever.
Analyzing the output
You will see that the Axis2 server generates a quote every 5 seconds and that the ESB receives the stock quote response. This is because the injected message is sent to the sample Axis2 server, which sends back a response to the ESB.