A JMS synchronous invocation takes place when a JMS producer receives a response to a JMS request produced by it when invoked. WSO2 ESB uses an internal JMS correlation ID to correlate the request and the response. See JMS Request/Reply Example for more information.
JMS synchronous invocations are further explained in the following use case.
When the proxy service named
SMSSenderProxy receives an HTTP request, it publishes that request in a JMS queue named
SMSStore. Another proxy service named
SMSForwardProxy subscribes to messages published in this queue and forwards them to a back-end service named
SimpleStockQuoteService. When this back-end service returns an HTTP response, internal ESB logic is used to save that message as a JMS message in a JMS queue named
SMSReceiveNotification. Then this response is taken from the
SMSReceiveNotification queue and delivered to the client as an HTTP message using internal ESB logic.
The following sub sections explain how to execute this use case. WSO2 Message Broker is used as the JMS broker.
Before executing this use case, the following steps need to be carried out. See Integrating WSO2 ESB in MB Documentation for detailed instructions.
- WSO2 MB should be installed and set up. See Setting up WSO2 Message Broker.
WSO2 ESB should installed and set up. See Setting up WSO2 ESB. Specific entries that are required to be added to the
<ESB_HOME>/repository/conf/jndi.propertiesfile for this use case are as follows.
Item Value Queue
connectionfactory.QueueConnectionFactory = amqp://admin:[email protected]/carbon?brokerlist='tcp://localhost:5673'
Configuring the JMS publisher
Configure a proxy service named
SMSSenderProxy as shown below to accept messages sent via the HTTP transport, and to place those messages in the
SMSStore queue in WSO2 MB.
The endpoint of this proxy service uses the following properties to map the proxy service with WSO2 MB.
|Property||Value for this use case||Description|
|The destination in which the request received by the proxy service is stored.|
This property specifies the initial context factory to use. The value specified here should be the same as that specified in
|The location of the JNDI service provider.|
|queue||The destination type of the JMS message that will be generated by the proxy service.|
|The destination in which the response generated by the back-end service is stored.|
Since this is a two-way invocation, the OUT_ONLY property is not set in the In sequence.
Configuring the JMS consumer
Configure a proxy service named
SMSForwardProxy to consume messages from the
SMSStore queue in WSO2 MB and forward them to the back-end service.
transport.jms.Destination properties map this proxy service to the
SimpleStockQuoteService sample shipped with WSO2 ESB is used as the back-end service in this example. To invoke this service, the address URI of this proxy service is defined as
Start the back-end service
In this example, the
SimpleStockQuoteService serving as the back-end receives the message from the
SMSForwardProxy proxy service via the JMS transport. The response is sent by
SimpleStockQuoteService is published in the
SMSReceiveNotificationStore queue which was set as the value for the
transport.jms.ReplyDestination parameter of the
SMSSenderProxy proxy service. This allows the
SMSSenderProxy to pick the response and deliver it to the client.
The back-end service is started as follows.
- Execute the following command from the
- Execute the
Invoke the JMS publisher
Execute the following command from the
directory to invoke the
SMSSenderProxy proxy service you defined as the JMS publisher.
You will get the following response.