Producing JMS Messages¶
This section describes how to configure ESB Micro Integrator to send messages to a JMS Queue. In this example, the Micro Integrator accepts messages via HTTP and sends them to a JMS queue.
Synapse configuration¶
Given below is the synapse configuration of the proxy service that mediates the above use case. Note that you need to update the JMS connection URL according to your broker as explained below. See the instructions on how to build and run this example.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="http" startOnLoad="true">
<target>
<inSequence>
<property action="set" name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<send>
<endpoint>
<address uri="jms:/SimpleStockQuoteService?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue"/>
</endpoint>
</send>
</inSequence>
</target>
</proxy>
The Synapse artifacts used are explained below.
Artifact Type | Description |
---|---|
Proxy Service | A proxy service is used to receive messages and to define the message flow. |
Property Mediator | The OUT ONLY property is set to true , which indicates that the message exchange is one-way. |
Property Mediator | The FORCE_SC_ACCEPTED property is set to true , this property forces a 202 HTTP response to the client so that the client stops waiting for a response.. |
Send Mediator |
To send a message to a JMS queue, you should define the JMS connection URL as the endpoint address (which should be invoked via the Send mediator). There are two ways to specify the endpoint URL:
|
Info
To refer details on JMS transport parameters, you can follow JMS transport parameters used in the Micro Integrator.
Note
Be sure to replace the ' &
' character in the endpoint URL with '&
' to avoid the following exception:
com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '=' (code 61); expected a semi-colon after the reference for entity 'java.naming.factory.initial' at [row,col {unknown-source}
Build and run¶
Create the artifacts:
- Set up ESB Integration Studio.
- Create an integration project with an ESB Configs module and an Composite Exporter.
- Create the proxy service with the configurations given above.
- Deploy the artifacts in your Micro Integrator.
Set up the broker:
- Configure a broker with your Micro Integrator instance. Let's use Active MQ for this example.
- Start the broker.
- Start the Micro Integrator (after starting the broker).
Set up the back-end service:
- Download the back-end service.
- Extract the downloaded zip file.
- Open a terminal, navigate to the
axis2Server/bin/
directory inside the extracted folder. -
Execute the following command to start the axis2server with the SimpleStockQuote back-end service:
sh axis2server.sh
axis2server.bat
Invoke the proxy service by sending a simple message.
Top