<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy name="JMSBinaryProxy" transports="jms">
<target inSequence="BINARY_CBR_SEQ"/>
</proxy>
<sequence name="BINARY_CBR_SEQ">
<in>
<log level="full"/>
<property action="set" name="OUT_ONLY" value="true"/>
<class name="samples.mediators.BinaryExtractMediator">
<property name="offset" value="11"/>
<property name="length" value="4"/>
<property name="variableName" value="symbol"/>
<property name="binaryEncoding" value="utf-8"/>
</class>
<log level="custom">
<property name="symbol" expression="get-property('symbol')"/>
</log>
<switch source="get-property('symbol')">
<case regex="GOOG">
<send>
<endpoint>
<address
uri="jms:/dynamicTopics/mdd.GOOG?transport.jms.ConnectionFactoryJNDIName=TopicConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=topic"/>
</endpoint>
</send>
</case>
<case regex="MSFT">
<send>
<endpoint>
<address
uri="jms:/dynamicTopics/mdd.MSFT?transport.jms.ConnectionFactoryJNDIName=TopicConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=topic"/>
</endpoint>
</send>
</case>
<default/>
</switch>
</in>
</sequence>
</definitions>
Executing the Client
In this configuration, a proxy service has been defined to accept incoming JMS
messages. JMS messages contain binary payloads. User configures the offset, length,
and binary encoding of the text literal that Synapse should use for CBR. Configuration
simply routes the messages based on this text to different endpoints.
A JMS producer and two instances of a consumer used to demonstrate the CBR functionality.
Now run the first consumer using the following command.
ant mddconsumer -Djms_topic=mdd.MSFT
Now run the second consumer using the following command.
ant mddconsumer -Djms_topic=mdd.GOOG
Now run the market data producer to genenrate market data for symbol 'MSFT' using
the following command.
ant mddproducer -Dsymbol=MSFT
Now run the market data producer to genenrate market data for symbol 'GOOG' using
the following command.
ant mddproducer -Dsymbol=GOOG
You will see the below output in the client console(s) based on the symbol.
mddconsumer:
[java] Market data recived for symbol : topic://mdd.MSFT
[java] Market data recived for symbol : topic://mdd.MSFT