Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:
repository/samples/directory that includes all Integration profile samples is changed to
repository/samples/resources/directory that includes all artifacts related to the Integration profile samples is changed to
Objective: Demonstrate the usage of the Event Mediator to publish messages to event topics.
- Deploy the
SimpleStockQuoteServicein sample Axis2 server and start it on port 9000.
- Start ESB with the sample configuration: e.g.,
wso2ei-samples.sh -sn 460
<definitions xmlns="http://ws.apache.org/ns/synapse"> <sequence name="main"> <log/> <event topic="stockquote"/> </sequence> </definitions>
1) Add an event topic. See Adding a New Topic.
1.1) Enter the name "stockquote" for the topic and click "Add Topic."
1.2) This will create an event topic named "stockquote" and you will be directed to the "Topic Browser" tree view. The newly created topic will be shown in the tree.
2) Create a subscription. See Subscribing to a Topic.
2.1) Enter the value "http://localhost:9000/services/SimpleStockQuoteService" in the "Event Sink URL" field and click "Subscribe."
3) Now run the sample client as follows to send a request to the main sequence.
ant stockquote -Dtrpurl=http://localhost:8280 -Dmode=placeorder
The request will be published to the "stockquote" topic by the Event Mediator and as a result the subscriber (Axis2 server in this case) will receive a copy of the message. You will see a log entry in the Axis2 server console indicating the receipt of the place order request.
The provided ESB configuration does not explicitly specify the endpoint of the Axis2 server. Also we don't set the actual EPR of the service on the request when sending the message from the client either. Therefore the only reason that Axis2 receives the message is because it is subscribed to the "stockquote" event topic.