This documentation is for WSO2 Enterprise Service Bus version 5.0.0. For the latest ESB, view the latest WSO2 Enterprise Integrator documentation.

All docs This doc
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Restricted to nilmini@wso2.com!

This sample demonstrates how one-way message bridging from JMS to HTTP can be done using the inbound JMS endpoint. 

Prerequisites

  • Copy the following JAR files from the <EI_HOME>/wso2/broker/client-lib folder to the <EI_HOME>/lib folder.
    • andes-client-3.2.19.jar
    • geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
    • org.wso2.securevault-1.0.0-wso2v2.jar
  • Open <EI_HOME>/conf/jndi.properties file and make a reference to the Message Broker as specified below (Use carbon as the virtual host).

    # register some connection factories
    # connectionfactory.[jndiname] = [ConnectionURL]
    connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'
    connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'
    # register some queues in JNDI using the form
    # queue.[jndiName] = [physicalName]
    queue.JMSMS=JMSMS
    # register some connection factories
    # connectionfactory.[jndiname] = [ConnectionURL]
    connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'
    connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5675'
    # register some topics in JNDI using the form
    # topic.[jndiName] = [physicalName]
    topic.MyTopic=MyTopic
  • Open the axis2.xml file (from the <EI_HOME>/conf/ directory), and uncomment the relevant JMS listener and JMS sender:

    • JMS listener configuration

      <!--Uncomment this and configure as appropriate for JMS transport support with WSO2 MB 2.x.x -->
          <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
              <parameter name="myTopicConnectionFactory" locked="false">
                 <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
                  <parameter name="java.naming.provider.url" locked="false">conf/jndi.properties</parameter>
                  <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter>
                  <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter>
              </parameter>
              <parameter name="myQueueConnectionFactory" locked="false">
                  <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
                  <parameter name="java.naming.provider.url" locked="false">conf/jndi.properties</parameter>
                  <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
                 <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
              </parameter>
      
              <parameter name="default" locked="false">
                  <parameter name="java.naming.factory.initial" locked="false">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter>
                  <parameter name="java.naming.provider.url" locked="false">conf/jndi.properties</parameter>
                  <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter>
                  <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>
              </parameter>
          </transportReceiver>
    • JMS sender configuration

      <!-- uncomment this and configure to use connection pools for sending messages-->
      <transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
  • Create a new sample file named synapse_sample_908.xml with one of the following configurations and add it to the <EI_HOME>/samples/service-bus/ directory.

    <definitions xmlns="http://ws.apache.org/ns/synapse"> 
    	<registry provider="org.wso2.carbon.mediation.registry.WSO2Registry"> 
    <parameter name="cachableDuration">15000</parameter> 
    </registry> 
    <taskManager provider="org.wso2.carbon.mediation.ntask.NTaskTaskManager"> 
    <parameter name="cachableDuration">15000</parameter> 
    </taskManager> 
    <inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="jms_inbound_queue" sequence="request" onError="fault" protocol="jms" suspend="false"> 
    <parameters> 
    <parameter name="interval">1000</parameter> 
    <parameter name="transport.jms.Destination">JMSMS</parameter> 
    <parameter name="transport.jms.CacheLevel">3</parameter> 
    <parameter name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</parameter> 
    <parameter name="sequential">true</parameter> 
    <parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> 
    <parameter name="java.naming.provider.url">conf/jndi.properties</parameter> 
    <parameter name="transport.jms.SessionAcknowledgement">AUTO_ACKNOWLEDGE</parameter> 
    <parameter name="transport.jms.SessionTransacted">false</parameter> 
    <parameter name="transport.jms.ConnectionFactoryType">queue</parameter> 
    </parameters> 
    </inboundEndpoint> 
    <sequence name="request" onError="fault"> 
    <call> 
    <endpoint> 
    <address format="soap12" uri="http://localhost:9000/services/SimpleStockQuoteService"/> 
    </endpoint> 
    </call> 
    <drop/> 
    </sequence> 
    </definitions>
    <definitions xmlns="http://ws.apache.org/ns/synapse"> 
    <registry provider="org.wso2.carbon.mediation.registry.WSO2Registry"> 
    <parameter name="cachableDuration">15000</parameter> 
    </registry> 
    <taskManager provider="org.wso2.carbon.mediation.ntask.NTaskTaskManager"> 
    <parameter name="cachableDuration">15000</parameter> 
    </taskManager> 
    <inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="jms_inbound_topic" sequence="request" onError="fault" protocol="jms" suspend="false"> 
    <parameters> 
    <parameter name="interval">1000</parameter> 
    <parameter name="transport.jms.Destination">MyTopic</parameter> 
    <parameter name="transport.jms.CacheLevel">3</parameter> 
    <parameter name="transport.jms.ConnectionFactoryJNDIName">TopicConnectionFactory</parameter> 
    <parameter name="sequential">true</parameter> 
    <parameter name="java.naming.factory.initial">org.wso2.andes.jndi.PropertiesFileInitialContextFactory</parameter> 
    <parameter name="java.naming.provider.url">conf/jndi.properties</parameter> 
    <parameter name="transport.jms.SessionAcknowledgement">AUTO_ACKNOWLEDGE</parameter> 
    <parameter name="transport.jms.SessionTransacted">false</parameter> 
    <parameter name="transport.jms.ConnectionFactoryType">topic</parameter> 
    </parameters> 
    </inboundEndpoint> 
    <sequence name="request" onError="fault"> 
    <call>
    <endpoint> 
    <address format="soap12" uri="http://localhost:9000/services/SimpleStockQuoteService"/> 
    </endpoint> 
    </call> 
    <drop/> 
    </sequence> 
    </definitions>

Building the sample

Follow the steps given below.

  1. First, start the Message Broker profile of WSO2 EI. See the instructed here.
  2. Start the ESB of WSO2 EI with the sample 908 configuration. For instructions on starting a sample configuration, see Starting a sample configuration.
  3. Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.
  4. Deploy the back-end service SimpleStockQuoteService. For instructions on deploying sample back-end services, see Deploying sample back-end services.

Now you have running instances of the ESB profile, the Message Broker profile, and you have a back-end service deployed in the Axis2 server. In the next section, we will send a message to the back-end service through WSO2 EI using a sample client.

Executing the sample

Follow the steps given below.

  1. Open the management console using https://localhost:9446/carbon, and log in using admin as the username as well as the password.
  2. You can see that the jmsms queue is created in the queue list, or that the mytopic topic is created in the topic list. Given below is a sample message you can use.

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
      <soap:Header/>
      <soap:Body>
         <ser:getQuote>
            <ser:request>
               <xsd:symbol>WSO2</xsd:symbol>
            </ser:request>
         </ser:getQuote>
      </soap:Body>
    </soap:Envelope>
  3. To publish message the message to the queue/topic, do the following

    • For Queues: Click Publish Messages for the jmsms queue, copy the above message to the Message Body field, and click Send Message.

    • For Topics: Click Details of the mytopic topic, copy the above message to the Text Message field, and click Publish.

Analyzing the output

You will see that the JMS endpoint gets the message from the queue or topic and sends it to the stock quote service. You will see the following log in the terminal of the Axis2 server:

Generating quote for : WSO2
  • No labels