Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section explains, through an example scenario, how the Message Broker EIP can be implemented using WSO2 ESB. The following topics are covered:

Table of Contents
maxLevel5

...

Code Block
languagehtml/xml
linenumberstrue
<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy xmlns="http://ws.apache.org/ns/synapse"  <proxy name="StockQuoteProxy"name="StockQuoteProxy" transports="http https" startOnLoad="true">
    <description/>
      transports="http"<target>
        <inSequence>
            <property name="OUT_ONLY" value="true"/>
          startOnLoad   <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
          trace="disable">  <property name="transport.jms.ContentTypeProperty" value="Content-Type" scope="axis2"/>
          <description/>   <send>
       <target> 			<!-- Send message to WSO2 MB -->  <endpoint>
       <endpoint>             <address uri="jms:/myqueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&amp;java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&amp;java.naming.provider.url=repository/conf/jndi.properties&amp;transport.jms.DestinationType=queue"/>
                </endpoint>
          <inSequence>  </send>
        </inSequence>
    <property name="OUT_ONLY" value="true"/>    <outSequence>
            <property name="FORCETRANSPORT_SC_ACCEPTEDHEADERS" valuescope="trueaxis2" scopeaction="axis2remove"/>
            <property name="transport.jms.ContentTypeProperty"<send/>
        </outSequence>
    </target>
</proxy>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxyConsumer" transports="jms" startOnLoad="true">
    <description/>
  value="Content-Type"  <target>
        <inSequence>
            <property  scopename="OUT_ONLY" value="axis2true"/>
         </inSequence>     <log level="full">
    <outSequence>             <property name="TRANSPORT_HEADERSSubscriber" scopevalue="axis2" action="remove"I am Subscribed to messages coming to StockQuoteProxy."/>
            <send/></log>
            <<drop/outSequence>>
        </target>inSequence>
   </proxy>    <sequence name="fault"> <outSequence>
      <log level="full">     <send/>
    <property name="MESSAGE" value="Executing default &#34;fault&#34; sequence"/> </outSequence>
    </target>
    <property<parameter name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
 transport.jms.DestinationType">queue</parameter>
    <parameter name="transport.jms.Destination">myqueue</parameter>
    <parameter name="transport.jms.ContentType">
       <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/ <rules xmlns="">
      </log>      <jmsProperty>contentType</jmsProperty>
      <drop/>    </sequence>  <default>application/xml</default>
 <sequence name="main">      </rules>
<log/>    </parameter>
  <drop/>  <parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
</sequence>proxy>
</definitions>



Simulating the sample scenario

Send a request using Stock Quote client to the proxy service in the following manner. For information on the Stock Quote client, refer to the Sample Clients section in WSO2 ESB documentation. 

ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy -Dsymbol=WSO2

You will not view a response in 

Note that the request is stored in WSO2 Message Broker. Any consumer can access the stored message by accessing  destinationMyQueue in WSO2 Message Broker.

How the implementation works

...

  • jms:/myqueue - Looks for a JNDI entry myqueue (see JNDI properties above).
  • ? - Separator indicating extra attributes.
  • transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory - Looks up ConnectionFactory in JNDI with name QueueConnectionFactory.
  • &amp;  - Separator (this will convert to ‘&’)
  • java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory -  Uses the andes properties-based JNDI.
  • &amp;  - Another separator (this will convert to ‘&’)
  • java.naming.provider.url=repository/conf/jndi.properties -  Looks in  repository/conf/jndi.properties for the JNDI properties file.