Introduction
In the first part, I have covered the basic setup of mule flows using queues to publish and consume JMS messages. In this part, I will cover request-response exchange pattern. Basically we want to publish a message to a JMS queue and then wait for reply from the consumer. The details about how this can be achieved using Java are clearly described at this articlehttp://activemq.apache.org/how-should-i-implement-request-response-with-jms.html
The Message Producer Configuration
The mule configuration for JMS endpoints has the exchange pattern of one-way or request-response. Check the request-response button as show in the figure below: The XML configuration looks like the following:1 2 | <jms:outbound-endpoint exchange-pattern= "request-response" queue= "queueOne" connector-ref= "Active_MQ" doc:name= "Order Queue Producer" > </jms:outbound-endpoint> |
Mule Flow Configuration
In order to demonstrate the request-response pattern, I created two flows, as shown in the following figure: The corresponding XML configuration is listed as the following:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <!--xml version= "1.0" encoding= "UTF-8" ?--> <mule xmlns:tracking= "http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw= "http://www.mulesoft.org/schema/mule/ee/dw" xmlns:http= "http://www.mulesoft.org/schema/mule/http" xmlns:jms= "http://www.mulesoft.org/schema/mule/jms" xmlns= "http://www.mulesoft.org/schema/mule/core" xmlns:doc= "http://www.mulesoft.org/schema/mule/documentation" xmlns:spring= "http://www.springframework.org/schema/beans" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd" > <flow name= "request-response-main_Flow" > <http:listener config-ref= "HTTP_Listener_Configuration" path= "/jms/twoway" allowedmethods= "POST" doc:name= "HTTP" > <dw:transform-message doc:name= "Json To Java" > <dw:set-payload><!--[CDATA[%dw 1.0 %output application/java --- payload]]--></dw:set-payload> </dw:transform-message> <set-property propertyname= "MULE_CORRELATION_ID" value= "custom_cid" doc:name= "Set Correlation ID" > <jms:outbound-endpoint exchange-pattern= "request-response" queue= "queueOne" connector-ref= "Active_MQ" doc:name= "Order Queue Producer" > <logger message= "#[payload]" level= "INFO" doc:name= "Logger" > </logger></jms:outbound-endpoint></set-property></http:listener></flow> <flow name= "Order-Consumer_Flow" > <jms:inbound-endpoint exchange-pattern= "request-response" queue= "queueOne" connector-ref= "Active_MQ" doc:name= "Order Queue Consumer" > <set-payload doc:name= "Set Payload" value= "Hello there" > </set-payload></jms:inbound-endpoint></flow> </mule> |
JMS Correlation ID
To set the correlation ID is critical to the request-response exchange pattern. Without this, the pattern will not work. Here is the how we can set the correlation ID:1 2 | < set-property propertyname = "MULE_CORRELATION_ID" value = "custom_cid" doc:name = "Set Correlation ID" > </ set-property > |
how we can map that correlation id to that response queue. want to send response to particular queue by using correaltion id. is is possible??
ReplyDelete
ReplyDeletethe blog is about mulesoft online course it is useful for students and Mulesoft Developers for more updates on mulesoft follow the link
mulesoft Online Training
For more info on other technologies go with below links
tableau online training hyderabad
ServiceNow Online Training
Python Online Training
ServiceNow Online Training
Hi Gary,
ReplyDeleteThank you for update from now onward I start to use MuleSoft in my training practice. Thank you for explaining each step-in screen shots. I use blogs for my easy reference which were quite useful to get started with.
I am an Oracle SOA developer, I am new to MuleSoft, can you plz advise me how to learn and any documentation.
Can you please explain difference between MuleSoft JMS Queue with ActiveMQ Library?
According to mule soft tutorials I am working on file adapter, my use case is read file from one location and write into another location can you please explain how can I approach this use case in MuleSoft?
I recommend Videos Courses from MuleSoft Training on Mac and Windows.
I want to learn MuleSoft ESB , I am not a java resource, weather I am eligible to learn lot required to learn Java also.
Please guide me and how the future market of the Mule looks like?
Anyways great write up, your efforts are much appreciated.
Muchas Gracias,
Kishore
ReplyDeletethe blog is good and Interactive it is about Mulesoft API Developer it is useful for students and Mulesoft Developers for more updates on Mulesoft mulesoft Online training
ReplyDeleteAn awesome blog for the freshers. Thanks for posting this information.
Mulesoft Self Learning
Best Mulesoft Training