Sample 502: Transforming Events Before Publish

<definitions xmlns="http://ws.apache.org/ns/synapse"> <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="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 how to mediate and transform events before they are sent to the target event sinks

Pre-requisites

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

Executing the Client

In this sample, the event (order request) is transformed into a new order with a different namesapce using the XSLT mediator. Invoke the client as follows.

ant eventsender

Event will be mediated through the 'PublicEventSource' sequence and get transformed before it gets published to the event sink (Axis2 server).

Back to Catalog