Sample 908: Inbound Endpoint with WSO2 Message Broker
This sample demonstrates how one-way message bridging from JMS to HTTP can be done using the inbound JMS endpoint of the ESB. The JMS inbound protocol implementation in the ESB requires an active JMS server instance to receive the messages that will be consumed by the ESB. This sample uses WSO2 Message Broker (WSO2 MB) as the JMS server. If you are using ActiveMQ as your JMS server, see Sample 901.
Prerequisites
Download and setup WSO2 MB. Instructions can be found in the section on setting up WSO2 MB.
- Copy the following JAR files from the
<MB_HOME>/client-lib
folder to the<ESB_HOME>/repository/components/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 the jndi
.properties
file from the<ESB_HOME>/repository/conf/
directory and make a reference to WSO2 MB as specified below (use carbon as the virtual host). Use either queues or topics.Create a new sample file named synapse_sample_908.xml with one of the following configurations and add it to the
<ESB_HOME>/repository/samples/
directory. Select the configuration for queues, or topics, based on how you defined the jndi.properties file above.
Building the sample
Follow the steps given below.
- First, start the WSO2 MB server. See the instructions here.
- Start the ESB with the sample 908 configuration. For instructions on starting a sample configuration, see Starting the ESB with a sample configuration.
- Start the Axis2 server. For instructions, see Starting the Axis2 server.
- 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, the Message Broker, 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 the ESB.
Executing the sample
Follow the steps given below.
Open the management console of WSO2 MB, and log in using
admin
as the username as well as the password. You can see that the 'jmsms' queue is created in the queue list, or that the 'mytopic' topic is created in the topic list.Now you can publish the following message to the queue or the topic:
<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>
To publish 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