You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by frankie_hr <fr...@2e-systems.com> on 2011/04/21 12:27:21 UTC

Problem with getting response in synchronous route

Hi everyone!

I'm having this problem with synchronous routes and passing objects back to
the caller.

The route is defined as:

public static final String BEAN = "bean:";
public static final String METHOD = "?method=";

from("activemq:queue:start")
    .inOut()
    .to(BEAN + "handler" + METHOD + "printType")		// prints the object type
    .to(BEAN + "handler" + METHOD + "returnsListOfB")		// returns a List
with 3 elements of type B

    .split(body())						// splits the list into individual type B elements
    .aggregationStrategy(new UseLatestAggregationStrategy())

    .to(BEAN + "handler" + METHOD + "printType")		// prints the object type
    .to("activemq:queue:continue");
        
        
from("activemq:queue:continue")
    .inOut()
    .to(BEAN + "handler" + METHOD + "printType")		// prints the object type
    .to(BEAN + "handler" + METHOD + "doesNothing");		// makes absolutely no
changes to the object passed in


The object being put on to the "start" queue is of type A. All of the
methods are very basic and do exactly what their names say. What I expect is
an object of type B to be returned upon making a call such as this one:


    A a = new A();
    Object o = camelTemplate.requestBody("activemq:queue:start", a);


Instead, I get the following exception after the object has reached the end
of the route and nothing was passed back:


org.apache.camel.ExchangeTimedOutException: The OUT message was not received
within: 20000 millis. Exchange[Message: com.ee.jbube.temporary.A@1c493dca]
	at
org.apache.camel.component.jms.reply.ReplyManagerSupport.processReply(ReplyManagerSupport.java:109)
	at
org.apache.camel.component.jms.reply.TemporaryQueueReplyHandler.onTimeout(TemporaryQueueReplyHandler.java:59)
	at
org.apache.camel.component.jms.reply.CorrelationMap.onEviction(CorrelationMap.java:34)
	at
org.apache.camel.component.jms.reply.CorrelationMap.onEviction(CorrelationMap.java:26)
	at
org.apache.camel.util.DefaultTimeoutMap.purge(DefaultTimeoutMap.java:202)
	at org.apache.camel.util.DefaultTimeoutMap.run(DefaultTimeoutMap.java:154)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
	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)


Interesting enough is the fact that when I replace all of the
"activemq:queue" statements with "seda", everything works just perfectly!
The version of Camel I'm using is 2.5.0 and ActiveMQ is 5.4.2.


Does anyone know what I'm doing wrong here? Thank you!

Frankie



--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-getting-response-in-synchronous-route-tp4330451p4330451.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with getting response in synchronous route

Posted by frankie_hr <fr...@2e-systems.com>.
Hi Ashwin,

thank you for your reply. I looked at the example you gave me and saw that
the route contains only a single queue. When I ran my JUnit test using only
a single queue (activemq:queue:start), I did get a proper reply back. The
timeout only happens when I try to pass something onto the other queue
(activemq:queue:continue) from the first queue.

Here is the definition of the Handler bean and the corresponding methods.
Some of the methods are void, but the message should just be passed further
even though they don't return anything specific.
http://camel.465427.n5.nabble.com/file/n4330690/Handler.java Handler.java 

Regards,
Frankie

--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-getting-response-in-synchronous-route-tp4330451p4330690.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with getting response in synchronous route

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

Please check out the following example and modify your code accordingly

https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyFixedReplyToInEndpointTest.java?view=markup
JmsRequestReplyFixedReplyToInEndpointTest 

Note the transform(...) at the end of the route in the example... It is
possible that your bean is not doing a proper return of the exchange.

Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
CamelOne 2011: http://fusesource.com/camel2011 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-getting-response-in-synchronous-route-tp4330451p4330540.html
Sent from the Camel - Users mailing list archive at Nabble.com.