You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by agustino <si...@yahoo.com> on 2012/08/21 11:31:22 UTC

How to use request reply in JMS

Hi All,

Is there any example for request reply in JMS? Currently I am using camel
2.10
from("activemq://queue:INPUT.Q?jmsMessageType=Object")
        .setExchangePattern(ExchangePattern.InOut).
       
.to("activemq://queue:OUTPUT.Q?jmsMessageType=Object&replyTo=REPLY.Q").process(new
Processor() {
          
          @Override
          public void process(Exchange exchange) throws Exception {
            exchange.getOut().setBody("Hello World");
          }
        });

I get this error:
The OUT message was not received within: 20000 millis due reply message with
correlationID: ID-JCSS047-63163-1345541374562-0-2 not received.
Exchange[JmsMessage[JmsMessageID: ID:JCSS047-63159-1345541364315-0:2:1:1:1]]
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1221)
	at
org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:187)
	at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:108)
	at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)
	at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)
	at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)
	at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)
	at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)
	at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)
	at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)
	at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)




--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-request-reply-in-JMS-tp5717752.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use request reply in JMS

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Aug 21, 2012 at 12:45 PM, agustino <si...@yahoo.com> wrote:
> Hi,
>
> The problem occurs only when I have .to syntax inside the code.
> In this case
> .to("activemq://queue:OUTPUT.Q?jmsMessageType=Object&replyTo=REPLY.Q") cause
> the error that was stated in the stack trace above.
>
> I have put replyToType=Exclusive as well but it still give me the error.
>

Make sure someone is listening on OUTPUT.Q and sending back a message
to REPLY.Q.
You get this exception because Camel timed out after 20 seconds. You
can adjust this value if you need longer timeout.

> Thanks.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-use-request-reply-in-JMS-tp5717752p5717761.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: How to use request reply in JMS

Posted by agustino <si...@yahoo.com>.
Hi,

The problem occurs only when I have .to syntax inside the code.
In this case
.to("activemq://queue:OUTPUT.Q?jmsMessageType=Object&replyTo=REPLY.Q") cause
the error that was stated in the stack trace above.

I have put replyToType=Exclusive as well but it still give me the error.

Thanks.




--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-request-reply-in-JMS-tp5717752p5717761.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to use request reply in JMS

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Just configure the name of the reply queue on the from uri. You may
want to configure the reply queue as being exclusive then it runs
faster. Then when the route completes, the message will be send back
to the reply queue. eg in the example below, after the processor has
run, the message containing "Hello World" will be send back to the
OUTPUT.Q.

from("activemq://queue:INPUT.Q?jmsMessageType=Object&replyTo=OUTPUT.Q&replyToType=Exclusive")
.process(new
 Processor() {
           @Override
           public void process(Exchange exchange) throws Exception {
             exchange.getOut().setBody("Hello World");
           }
         });

I suggest to read the JMS page. It has sections about request/reply
etc, and some pointers how and what to look out for. And what to
configure etc.
http://camel.apache.org/jms

And mind that you can use 3 kind of queues when doing request/reply
- temporary queue
- shared queue
- exclusive queue

So mind the difference.



On Tue, Aug 21, 2012 at 11:31 AM, agustino <si...@yahoo.com> wrote:
> Hi All,
>
> Is there any example for request reply in JMS? Currently I am using camel
> 2.10
> from("activemq://queue:INPUT.Q?jmsMessageType=Object")
>         .setExchangePattern(ExchangePattern.InOut).
>
> .to("activemq://queue:OUTPUT.Q?jmsMessageType=Object&replyTo=REPLY.Q").process(new
> Processor() {
>
>           @Override
>           public void process(Exchange exchange) throws Exception {
>             exchange.getOut().setBody("Hello World");
>           }
>         });
>
> I get this error:
> The OUT message was not received within: 20000 millis due reply message with
> correlationID: ID-JCSS047-63163-1345541374562-0-2 not received.
> Exchange[JmsMessage[JmsMessageID: ID:JCSS047-63159-1345541364315-0:2:1:1:1]]
>         at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1221)
>         at
> org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:187)
>         at
> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:108)
>         at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)
>         at
> org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)
>         at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)
>         at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:325)
>         at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:263)
>         at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1058)
>         at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1050)
>         at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>         at java.lang.Thread.run(Thread.java:662)
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-use-request-reply-in-JMS-tp5717752.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen