Sample 500: Introduction to Eventing

<definitions xmlns=""> <eventSource name="SampleEventSource"> <subscriptionManager class="org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager"> <!--property name="registryURL" value="http://localhost:8180/wso2registry"/> <property name="username" value="admin"/> <property name="password" value="admin"/--> <property name="topicHeaderName" value="Topic"/> <property name="topicHeaderNS" value=""/> </subscriptionManager> </eventSource> <sequence name="PublicEventSource"> <log level="full"/> <eventPublisher eventSourceName="SampleEventSource"/> </sequence> <proxy name="EventingProxy"> <target inSequence="PublicEventSource"/> </proxy> </definitions>


Demonstrate the use of the Eventing functionality built into Synapse


  • Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
  • Start Synapse using the configuration numbered 500 (repository/conf/sample/synapse_sample_500.xml)
    Unix/Linux: sh -sample 500
    Windows: synapse.bat -sample 500

Executing the Client

In this sample an event source is creted based on the provided configuration. Event subscriber subscribes for the events, Event sender publishes events and the SimpleStockQuoteService acts as the Event Sink.

First, invoke the sample client (Subscriber) as follows.

ant eventsubscriber

This will create a new subscription with the SimpleStockQuoteService deployed on the sample Axis2 server acting as the sink. Whenever a new event is published, SimpleStockQuoteService will receive a message with that event. You should see a message like this on the client console confirming the subscription.

[java] Subscription identifier: urn:uuid:6989F66706E73C69F5259116575749162017010321

You will need this identifier to modify the subscription in the next steps. Now, invoke the client (Sender) as follows.

ant eventsender

This will send a placeOrder request to the EventingProxy. You should see a message in the Synapse logs. Note the presence of the following SOAP header in the request.

<aip:Topic xmlns:aip="">synapse/event/test</aip:Topic>

Since there is a single subscription with SimpleStockQuoteService as the sink, Synapse will send the message to the sample Axis2 server and you should see the following message in its logs:

Accepted order for : 1000 stocks of GOOG at $ 10.1

You can also send various other WS-Eventing messages from the sample client to modify the subscription details. To get the current status of the subscription, invoke the client as follows.

ant eventsubscriber -Dmode=getstatus -Didentifier=<identifier>

To renew the subscription, invoke the client as follows.

ant eventsubscriber -Dmode=renew -Didentifier=<identifier> -Dexpires=2012-12-31T21:07:00.000-08:00

Finally, in order to unsubscribe, use the following command.

ant eventsubscriber -Dmode=unsubscribe -Didentifier=<identifier>

Back to Catalog