You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Laci Gaspar <la...@gmail.com> on 2016/02/04 09:57:26 UTC

request reply

Hi
I was playing around with request / reply a  bit and found something I 
can't understand.
When I run the followin snippet:

     @Produce(uri = "direct:start")
     protected ProducerTemplate start;
     @EndpointInject(uri = "mock:end")
     protected MockEndpoint mockEnd;

     @Test
     public void test002() throws InterruptedException {

         mockEnd.expectedMessageCount(1);
         String message = "my message";
         logger.info("Sending Message:" + message);
         start.requestBody(message);
         assertMockEndpointsSatisfied();
     }

My routes are the following:

from("direct:start").log("starting....").to("JMSConnectionFactory:queue:replier?replyTo=replyToQueue")
                         .log("back from 
replier").log("Body:${body}").to("mock:end");
from("JMSConnectionFactory:queue:replier").log("in replier...");
from("JMSConnectionFactory:queue:replyToQueue").log("we are in 
replyToQueue");


Then I get the following result:
[                          main] route1 INFO  starting....
[                          main] QueueReplyManager              WARN 
Endpoint[JMSConnectionFactory://queue:replier?replyTo=replyToQueue] is 
using a shared reply queue, which is not as fast as alternatives. See 
more detail at the section 'Request-reply over JMS' at 
http://camel.apache.org/jms
[read #0 - JmsConsumer[replier]] TransportConnector             INFO  
Connector vm://localhost started
[read #0 - JmsConsumer[replier]] route2                         INFO  in 
replier...
[#1 - JmsConsumer[replyToQueue]] route3                         INFO  we 
are in replyToQueue
[#1 - JmsConsumer[replyToQueue]] route3                         INFO  we 
are in replyToQueue
[#1 - JmsConsumer[replyToQueue]] route3                         INFO  we 
are in replyToQueue
[#1 - JmsConsumer[replyToQueue]] route3                         INFO  we 
are in replyToQueue
[#1 - JmsConsumer[replyToQueue]] route3                         INFO  we 
are in replyToQueue
[#1 - JmsConsumer[replyToQueue]] route3                         INFO  we 
are in replyToQueue
[ueueReplyManager[replyToQueue]] route1                         INFO  
back from replier
[ueueReplyManager[replyToQueue]] route1                         INFO  
Body:my message
[                          main] MockEndpoint                   INFO  
Asserting: Endpoint[mock://end] is satisfied

What I don't understand are the lines: "we are in replyToQueue". Why is 
the route run several times (the number differs from test to test)?

Thanks,
Laci



Re: request reply

Posted by Claus Ibsen <cl...@gmail.com>.
You should not have a route that consumes from the replyTo queue as
you will consume the message that was intended for the reply.



On Thu, Feb 4, 2016 at 9:57 AM, Laci Gaspar <la...@gmail.com> wrote:
> Hi
> I was playing around with request / reply a  bit and found something I can't
> understand.
> When I run the followin snippet:
>
>     @Produce(uri = "direct:start")
>     protected ProducerTemplate start;
>     @EndpointInject(uri = "mock:end")
>     protected MockEndpoint mockEnd;
>
>     @Test
>     public void test002() throws InterruptedException {
>
>         mockEnd.expectedMessageCount(1);
>         String message = "my message";
>         logger.info("Sending Message:" + message);
>         start.requestBody(message);
>         assertMockEndpointsSatisfied();
>     }
>
> My routes are the following:
>
> from("direct:start").log("starting....").to("JMSConnectionFactory:queue:replier?replyTo=replyToQueue")
>                         .log("back from
> replier").log("Body:${body}").to("mock:end");
> from("JMSConnectionFactory:queue:replier").log("in replier...");
> from("JMSConnectionFactory:queue:replyToQueue").log("we are in
> replyToQueue");
>
>
> Then I get the following result:
> [                          main] route1 INFO  starting....
> [                          main] QueueReplyManager              WARN
> Endpoint[JMSConnectionFactory://queue:replier?replyTo=replyToQueue] is using
> a shared reply queue, which is not as fast as alternatives. See more detail
> at the section 'Request-reply over JMS' at http://camel.apache.org/jms
> [read #0 - JmsConsumer[replier]] TransportConnector             INFO
> Connector vm://localhost started
> [read #0 - JmsConsumer[replier]] route2                         INFO  in
> replier...
> [#1 - JmsConsumer[replyToQueue]] route3                         INFO  we are
> in replyToQueue
> [#1 - JmsConsumer[replyToQueue]] route3                         INFO  we are
> in replyToQueue
> [#1 - JmsConsumer[replyToQueue]] route3                         INFO  we are
> in replyToQueue
> [#1 - JmsConsumer[replyToQueue]] route3                         INFO  we are
> in replyToQueue
> [#1 - JmsConsumer[replyToQueue]] route3                         INFO  we are
> in replyToQueue
> [#1 - JmsConsumer[replyToQueue]] route3                         INFO  we are
> in replyToQueue
> [ueueReplyManager[replyToQueue]] route1                         INFO  back
> from replier
> [ueueReplyManager[replyToQueue]] route1                         INFO
> Body:my message
> [                          main] MockEndpoint                   INFO
> Asserting: Endpoint[mock://end] is satisfied
>
> What I don't understand are the lines: "we are in replyToQueue". Why is the
> route run several times (the number differs from test to test)?
>
> Thanks,
> Laci
>
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2