You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Adarsh_GU <ad...@ibsplc.com> on 2016/05/18 07:16:40 UTC

Camel jms - In Out Pattern

Hi, iam new to camel,Im trying to implement a synchronous request-reply
mechanism using camel component.
I have 2  wmq queues 
*1. requestQuee - application will send requests to this queue
2. responseQueue  - application will have to listen & receive response from
this queue *


    /   <route id="jms-sync-route">
                     <camel:from uri="direct:jms" />
                     <camel:to
uri="jms:queue:requestQuee?replyTo=queue:responseQueue&amp;exchangePattern=InOut"
/>
              </route> /


     /  <camel:route id="mockresponse">
              <camel:from
uri="jms:queue:requestQuee?concurrentConsumers=5"/>
              <camel:process ref="jmsResponseListener" />
              <camel:to uri="jms:queue:responseQueue"/>
       </camel:route>/


bean jmsResponseListener having logic
public class MockResponseGenerator implements Processor{
/
	public void process(Exchange ex) throws Exception {
		ex.getIn().setBody("<res>mockresponse</res>");
		String msgid=(String) ex.getIn().getHeader("JMSMessageID");
		if(msgid != null){
			ex.getIn().setHeader("JMSCorrelationID",msgid);
			
		}
	}

}/

*I getting error as follows,it is observed that. message is en queued to
requestQuee , but not de queued.*


/Caused by: org.apache.camel.ExchangeTimedOutException: The OUT message was
not received within: 20000 millis due reply message with correlationID:
Camel-ID-ICB1864-58611-1463553066644-3-9 not received on destination:
queue://responseQueue. Exchange[ID-ICB1864-58611-1463553066644-3-8][Message:
<?xml version="1.0" encoding="UTF-8"?></

*If i remove inout pattern.message is en queued to requestQuee and after
dequeed by mockresponse route ,eventually MockResponseGenerator  prepares
mock response and enqueued to responseQueue.*

Please update your suggestions to achieve the same. Thanks :)



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-jms-In-Out-Pattern-tp5782730.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel jms - In Out Pattern

Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
It looks like the other system isn’t setting the JMSCorrelationID, so the route is timing-out waiting for a response with that correlation ID.

Have you tried setting replyToType=Exclusive?  You can see the details in the camel-jms docs (http://camel.apache.org/jms.html <http://camel.apache.org/jms.html>).

> On May 18, 2016, at 1:16 AM, Adarsh_GU <ad...@ibsplc.com> wrote:
> 
> Hi, iam new to camel,Im trying to implement a synchronous request-reply
> mechanism using camel component.
> I have 2  wmq queues 
> *1. requestQuee - application will send requests to this queue
> 2. responseQueue  - application will have to listen & receive response from
> this queue *
> 
> 
>    /   <route id="jms-sync-route">
>                     <camel:from uri="direct:jms" />
>                     <camel:to
> uri="jms:queue:requestQuee?replyTo=queue:responseQueue&amp;exchangePattern=InOut"
> />
>              </route> /
> 
> 
>     /  <camel:route id="mockresponse">
>              <camel:from
> uri="jms:queue:requestQuee?concurrentConsumers=5"/>
>              <camel:process ref="jmsResponseListener" />
>              <camel:to uri="jms:queue:responseQueue"/>
>       </camel:route>/
> 
> 
> bean jmsResponseListener having logic
> public class MockResponseGenerator implements Processor{
> /
> 	public void process(Exchange ex) throws Exception {
> 		ex.getIn().setBody("<res>mockresponse</res>");
> 		String msgid=(String) ex.getIn().getHeader("JMSMessageID");
> 		if(msgid != null){
> 			ex.getIn().setHeader("JMSCorrelationID",msgid);
> 			
> 		}
> 	}
> 
> }/
> 
> *I getting error as follows,it is observed that. message is en queued to
> requestQuee , but not de queued.*
> 
> 
> /Caused by: org.apache.camel.ExchangeTimedOutException: The OUT message was
> not received within: 20000 millis due reply message with correlationID:
> Camel-ID-ICB1864-58611-1463553066644-3-9 not received on destination:
> queue://responseQueue. Exchange[ID-ICB1864-58611-1463553066644-3-8][Message:
> <?xml version="1.0" encoding="UTF-8"?></
> 
> *If i remove inout pattern.message is en queued to requestQuee and after
> dequeed by mockresponse route ,eventually MockResponseGenerator  prepares
> mock response and enqueued to responseQueue.*
> 
> Please update your suggestions to achieve the same. Thanks :)
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-jms-In-Out-Pattern-tp5782730.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel jms - In Out Pattern

Posted by Adarsh_GU <ad...@ibsplc.com>.
The issue was while using *inout pattern  with this mockresponse route* to
poll mock response to response quee.

 <camel:route id="mockresponse">
              <camel:from
uri="jms:queue:requestQuee?concurrentConsumers=5"/>
              <camel:process ref="jmsResponseListener" />
              <camel:to uri="jms:queue:responseQueue"/>
       </camel:route>

Now I tried with polling some response to response queue first, then i
removed above route .

In this case request response is working.
for each request it is picking up response from response queue (if response
with matching corelation id exists).

But didnt understand why request-reply didnt with above response polling
route :)




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-jms-In-Out-Pattern-tp5782730p5782781.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel jms - In Out Pattern

Posted by Adarsh_GU <ad...@ibsplc.com>.
The third party provider will give response only in their response quee,
thats why i set  replyTo as their response queue name.(instead of temp
queue), 
From queue console i have observed that while configuring request response

basically i have 2 queues from third party.one for sending request another
for getting response of that request. Im trying to make it as a synchronous
request reply call .*mockresponse* route fail to poll response message to
response queue
Note: mock response route is temporary route for polling reponse,will be
removed and later use actual response in responseQueue provided by third
party provider.

 <route id="jms-sync-route"> 
>                      <camel:from uri="direct:jms" /> 
>                      <camel:to 
> 
> uri="jms:queue:requestQuee?replyTo=queue:*responseQueue*&amp;exchangePattern=InOut" 
> /> 
>               </route> / 



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-jms-In-Out-Pattern-tp5782730p5782745.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel jms - In Out Pattern

Posted by Henryk Konsek <he...@gmail.com>.
Hi,

You don't have to send message to the response queue. Camel will create a
temporary response queue for you:

  from("jms:foo").setBody().constant("myresponse");
  ...
  String response = producerTemplate.requestBody("jms:foo", "body",
String.class);
  assertThat(response).isEqualTo("myresponse");

This is pretty convenient comparing to managing reply queue by yourself.

Cheers!

śr., 18.05.2016 o 09:22 użytkownik Adarsh_GU <ad...@ibsplc.com>
napisał:

> Hi, iam new to camel,Im trying to implement a synchronous request-reply
> mechanism using camel component.
> I have 2  wmq queues
> *1. requestQuee - application will send requests to this queue
> 2. responseQueue  - application will have to listen & receive response from
> this queue *
>
>
>     /   <route id="jms-sync-route">
>                      <camel:from uri="direct:jms" />
>                      <camel:to
>
> uri="jms:queue:requestQuee?replyTo=queue:responseQueue&amp;exchangePattern=InOut"
> />
>               </route> /
>
>
>      /  <camel:route id="mockresponse">
>               <camel:from
> uri="jms:queue:requestQuee?concurrentConsumers=5"/>
>               <camel:process ref="jmsResponseListener" />
>               <camel:to uri="jms:queue:responseQueue"/>
>        </camel:route>/
>
>
> bean jmsResponseListener having logic
> public class MockResponseGenerator implements Processor{
> /
>         public void process(Exchange ex) throws Exception {
>                 ex.getIn().setBody("<res>mockresponse</res>");
>                 String msgid=(String) ex.getIn().getHeader("JMSMessageID");
>                 if(msgid != null){
>                         ex.getIn().setHeader("JMSCorrelationID",msgid);
>
>                 }
>         }
>
> }/
>
> *I getting error as follows,it is observed that. message is en queued to
> requestQuee , but not de queued.*
>
>
> /Caused by: org.apache.camel.ExchangeTimedOutException: The OUT message was
> not received within: 20000 millis due reply message with correlationID:
> Camel-ID-ICB1864-58611-1463553066644-3-9 not received on destination:
> queue://responseQueue.
> Exchange[ID-ICB1864-58611-1463553066644-3-8][Message:
> <?xml version="1.0" encoding="UTF-8"?></
>
> *If i remove inout pattern.message is en queued to requestQuee and after
> dequeed by mockresponse route ,eventually MockResponseGenerator  prepares
> mock response and enqueued to responseQueue.*
>
> Please update your suggestions to achieve the same. Thanks :)
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-jms-In-Out-Pattern-tp5782730.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
-- 
Henryk Konsek
https://linkedin.com/in/hekonsek