com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.

Sample 381: Class Mediator to CBR Binary Messages

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Integration profile samples is changed to <EI_HOME>/samples/service-bus/.
  • <PRODUCT_HOME>/repository/samples/resources/ directory that includes all artifacts related to the Integration profile samples is changed to <EI_HOME>/samples/service-bus/resources/.

Objective: Demonstrate on CBR a message with binary payload

<definitions xmlns="http://ws.apache.org/ns/synapse"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://ws.apache.org/ns/synapse http://synapse.apache.org/ns/2010/04/configuration/synapse_config.xsd">

    <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>

Prerequisites:

  • Make sure the synapse-samples-1.0.jar is in your class path (by default this jar is placed in the lib directory when installing Synapse)
  • Configure the JMS transport using ActiveMQ as described in Setting Up the ESB Samples.
  • Start ESB with the sample configuration 381 (i.e. wso2esb-samples -sn 381)
  • Start the sample Axis2 server and deploy the SimpleStockQuoteService.

In this configuration, a proxy has configured to accept incoming JMS messages. JMS messages contains a binary payload. User configure the offset, length, binary encoding of the text literal that it need to use for CBR. And a variable name to set the decoded value as a property. Configuration simply route the messages based on the 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

So, now both consumers are ready to listen the topic. 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
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.