WSO2 ESB - Eventing Samples

Running the Eventing samples with WSO2 Enterprise Service Bus (ESB)

Sample 500: Simple Eventing Sample

 

<!-- Simple Eventing configuration -->
 <definitions xmlns="http://ws.apache.org/ns/synapse">
      <eventSource name="SampleEventSource">
            <subscriptionManager class="org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager">
                <property name="topicHeaderName" value="Topic"/>
                <property name="topicHeaderNS" value="http://apache.org/aip"/>
            </subscriptionManager>
      </eventSource>

     <sequence name="PublicEventSource" >
            <log level="full"/>
            <eventPublisher eventSourceName="SampleEventSource"/>
     </sequence>

     <proxy name="EventingProxy">
         <target inSequence="PublicEventSource" />
     </proxy>
 </definitions>

Objective: Demonstrate the use of the Eventing functionality built with synapse

Prerequisites:
Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000.

Start Synapse with the sample configuration 500 (i.e. wso2esb-samples -sn 500).

In this sample, the event source is created based on the above configuration. Event subscriber subscribes for the events, Event sender publish events and the SimpleStockQuoteService act as the Event Sink.

Invoke the client (Subscriber) as follows.

ant eventsubscriber

Invoke the client (Sender) as follows.

ant eventsender

Invoke the client (Un-Subscribe) as follows.

ant eventsubscriber -Dmode=unsubscribe -Didentifier=urn:uuid:6DFDF649A67416BFCC1228112473802909001-111373032

Invoke the client (Re-New) as follows.

ant eventsubscriber -Dmode=renew -Didentifier=urn:uuid:6DFDF649A67416BFCC1228112473802909001-111373032 -Dexpires=2009-12-31T21:07:00.000-08:00

Invoke the client (GetStatus) as follows.

ant eventsubscriber -Dmode=getstatus -Didentifier=urn:uuid:6DFDF649A67416BFCC1228112473802909001-111373032

Sample 501: EventSource with static subscriptions

 

<!-- Eventing configuration with static subscriptions-->
 <definitions xmlns="http://ws.apache.org/ns/synapse">
      <eventSource name="SampleEventSource">
            <subscriptionManager class="org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager">
                <property name="topicHeaderName" value="Topic"/>
                <property name="topicHeaderNS" value="http://apache.org/aip"/>
            </subscriptionManager>
            <subscription id="mysub1">
                 <filter source ="synapse/event/test" dialect="http://synapse.apache.org/eventing/dialect/topicFilter"/>
                 <endpoint><address uri="http://localhost:9000/services/SimpleStockQuoteService"/></endpoint>
            </subscription>
            <subscription id="mysub2">
                 <filter source ="synapse/event/test" dialect="http://synapse.apache.org/eventing/dialect/topicFilter"/>
                 <endpoint><address uri="http://localhost:9000/services/SimpleStockQuoteService"/></endpoint>
                 <expires>2020-06-27T21:07:00.000-08:00</expires>
            </subscription>
      </eventSource>

     <sequence name="PublicEventSource" >
            <log level="full"/>
            <eventPublisher eventSourceName="SampleEventSource"/>
     </sequence>

     <proxy name="EventingProxy">
         <target inSequence="PublicEventSource" />
     </proxy>
 </definitions>

Objective: Demonstrate static subscription capability of Synapse

Prerequisites:
Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000.

Start Synapse with the sample configuration 501 (i.e. wso2esb-samples -sn 501).

In this sample, two static subscriptions created by providing the SimpleStockQuoteService as the event sink.

Invoke the client (Sender) as follows.

ant eventsender

Event sender will send the events to the static subscriptions

Sample 502: Transform events before publish

 

<!-- Eventing configuration with transformation before publish-->
 <definitions xmlns="http://ws.apache.org/ns/synapse">
      <eventSource name="SampleEventSource">
            <subscriptionManager class="org.apache.synapse.eventing.managers.DefaultInMemorySubscriptionManager">
                <property name="topicHeaderName" value="Topic"/>
                <property name="topicHeaderNS" value="http://apache.org/aip"/>
            </subscriptionManager>
            <subscription id="mysub1">
                 <filter source ="synapse/event/test" dialect="http://synapse.apache.org/eventing/dialect/topicFilter"/>
                 <endpoint><address uri="http://localhost:9000/services/SimpleStockQuoteService"/></endpoint>
            </subscription>
      </eventSource>


     <sequence name="PublicEventSource">
            <log level="full"/>
            <xslt key="xslt-key-req"/>
            <log level="full"/>
            <eventPublisher eventSourceName="SampleEventSource"/>
     </sequence>

     <proxy name="EventingProxy">
         <target inSequence="PublicEventSource" />
     </proxy>

     <localEntry key="xslt-key-req" src="file:repository/conf/sample/resources/transform/transform_eventing.xslt"/>
 </definitions>

Objective: Demonstrate the mediation capability of events before publishing to event sink.

Prerequisites:
Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000.

Start Synapse with the sample configuration 502 (i.e. wso2esb-samples -sn 502).

In this sample, the event (order request) transform to a new order with different namespace using XSLT mediator.

Invoke the client (Sender) as follows.

ant eventsender

The event is published after transformation.

Sample 503: Using topic based remote registry as subscription manager

 

<definitions xmlns="http://ws.apache.org/ns/synapse">
     <eventSource name="SampleEventSource">
         <subscriptionManager
             class="org.wso2.carbon.eventing.impl.RemoteRegistryBasedSubscriptionManager">
             <property name="registryURL"
                 value="https://localhost:9446/registry/" />
             <property name="username" value="admin" />
             <property name="password" value="admin" />
             <property name="topicHeaderName" value="Topic" />
             <property name="topicHeaderNS"
                 value="http://apache.org/aip" />
         </subscriptionManager>
     </eventSource>

     <sequence name="PublicEventSource">
         <log level="full" />
         <eventPublisher eventSourceName="SampleEventSource" />
     </sequence>

     <proxy name="EventingProxy">
         <target inSequence="PublicEventSource" />
     </proxy>
 </definitions>

Objective: Demonstrate the usage of WSO2 registry as a topic based subscription manager.

Prerequisites: Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000. Run the WSO2 Registry in the local machine using the port 9446 (HTTPs).

Start Synapse with the sample configuration 503 (i.e. wso2esb-samples -sn 503).

In this sample, subscriptions stored in the WSO2 Registry,

Invoke the client eventsubscriber and eventsender as described in the sample 500.