camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" ...@silverbullet.dk>
Subject RE: Camel Router is blocked when waiting for response
Date Tue, 08 Jul 2008 17:22:03 GMT
See this unit test:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsConcurrentConsumersTest.java?view=markup


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Claus Ibsen [mailto:ci@silverbullet.dk] 
Sent: 8. juli 2008 18:54
To: camel-user@activemq.apache.org
Subject: RE: Camel Router is blocked when waiting for response

Hi

The JMS stuff is really a James question but I dare to give the answer.

The JMS component has many options:
http://activemq.apache.org/camel/jms.html

The one you are looking for is concurrentConsumers
Default it is set to 1 so Camel will only allow one consumer at a time.

You can increase this value to be able to work in parallel.

I am working on a unit test that demonstrates this behavior:

Output from 5 threads sending a message to your route with: concurrentConsumers=2

Starting thread #0
Starting thread #1
Starting thread #2
Starting thread #4
Starting thread #3
Recived: Hello World #0
Recived: Hello World #4
Asserting response #4
Asserting response #0
Recived: Hello World #1
Recived: Hello World #2
Asserting response #2
Asserting response #1
Recived: Hello World #3
Asserting response #3

And of course with concurrentConsumers=5 they all run in parallel:
Starting thread #0
Starting thread #2
Starting thread #4
Starting thread #1
Starting thread #3
Recived: Hello World #2
Recived: Hello World #0
Recived: Hello World #4
Recived: Hello World #1
Recived: Hello World #3
Asserting response #1
Asserting response #2
Asserting response #3
Asserting response #0
Asserting response #4


    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
                from("activemq:a?concurrentConsumers=3").to("activemq:b?concurrentConsumers=3");

                from("activemq:b?concurrentConsumers=3").process(new Processor() {
                    public void process(Exchange exchange) throws Exception {
                        System.out.println("Recived: " + exchange.getIn().getBody(String.class));
                        Thread.sleep(1000);
                        exchange.getOut().setBody("Bye World");
                    }
                });
            }
        };
    }

Process finished with exit code 1

Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: S.R. [mailto:srassokhin@gmail.com] 
Sent: 8. juli 2008 13:04
To: camel-user@activemq.apache.org
Subject: Camel Router is blocked when waiting for response


For example, I have the following route:

// main route
from("jms:testQueue").to("jms:someOtherQueue");

// and test consumer for "jms:someOtherQueue"
from("jms:someOtherQueue").process(new Processor() {
       public void process(Exchange exchange) throws Exception {       
                Thread.sleep(10000);
                exchange.getOut().setBody("Reply");
       }
});

It's easy to see that when we send request message (with JMSReplyTo field
set) to the jms:testQueue, the Camel Router is blocked until reply from
jms:someOtherQueue consumer is received, therefore new incoming messages
can't be processed/routed during this time.

Does Camel have some abilities or configuration settings to avoid this, and
make this waiting asynchronous, so that other messages could be processed
even if some of the previous messages hasn't been completely
processed/routed yet?

Thank you,
Sergey
-- 
View this message in context: http://www.nabble.com/Camel-Router-is-blocked-when-waiting-for-response-tp18336673s22882p18336673.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message