You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by rogelio_sevilla1 <ro...@gmail.com> on 2011/06/29 19:08:09 UTC

concurrentConsumers basic question

Hello everyone,  sorry if this is too basic.

I'm beginning to use Camel (along with Fuse ESB but that's another story) , 
and i'm doing some basic tests while reading "camel in action" (excellent
book by the way). Anyway, i was trying an activemq concurrent example, and i
configured it like this on my spring file:



 <bean id="jmsConnectionFactory" 
   class="org.apache.activemq.ActiveMQConnectionFactory">
   <property name="brokerURL" value="vm://localhost" />
   
</bean>

<bean id="pooledConnectionFactory" 
   class="org.apache.activemq.pool.PooledConnectionFactory">
   <property name="maxConnections" value="8" />
   <property name="maximumActive" value="500" />
   <property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>

<bean id="jmsConfig" 
   class="org.apache.camel.component.jms.JmsConfiguration">
   <property name="connectionFactory" ref="pooledConnectionFactory"/>
   <property name="transacted" value="false"/>
 * <property name="maxConcurrentConsumers" value="10"/>*
</bean>

<bean id="activemq" 
    class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="configuration" ref="jmsConfig"/>
</bean>


*And I have a simple route doing this:*


from("activemq:incomingOrders").to("activemq:topic:xmlOrders")  

          from("activemq:topic:xmlOrders").to("activemq:accounting");   
          from("activemq:topic:xmlOrders").to("activemq:production");   


*Accounting and production have a processos printing something like this: *

Accounting received the order from: dummy.xml
Production received the order from: dummy.xml


The problem is that, when I use the *<property name="concurrentConsumers"
value="10"/>*  option  on my spring configuration file,  the
*activemq:accounting* and *activemq:production* are getting the message more
than once (around 7 times each one), and when i use the config    
*<property name="maxConcurrentConsumers" value="10"/>*  everything works ok. 
does concurrentConsumers force the usage of more threads even if they are
not needed??, what's the correct usage of concurrentConsumers??

Sorry if this is too basic, and thanks for your time :-D







--
View this message in context: http://camel.465427.n5.nabble.com/concurrentConsumers-basic-question-tp4535789p4535789.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: concurrentConsumers basic question

Posted by rogelio_sevilla1 <ro...@gmail.com>.
Thanks a lot mr. O'Day for the correction, and thanks to everyone else  for
the time taken to answer my question :-D 

--
View this message in context: http://camel.465427.n5.nabble.com/concurrentConsumers-basic-question-tp4535789p4539262.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: concurrentConsumers basic question

Posted by boday <be...@initekconsulting.com>.
you are getting duplicates because the topic has up to 10 concurrent
consumers based on your jmsConfig...

so should either change the jmsConfig (used by all routes) or explicitly set
these on any routes in question...

from("activemq:topic:xmlOrders?maxConcurrentConsumers=1&concurrentConsumers=1")
.to("activemq:accounting"); 


rogelio_sevilla1 wrote:
> 
> thanks for the answer Mr. Pham, I've commented my "concurrent configs" on
> my spring file and I've done it the way you propose:
> 
> 
> from("activemq:topic:xmlOrders").to("activemq:accounting?concurrentConsumers=5"); 
> 
> 
> Thanks for the advice. However, the  activemq:accounting queue is still
> getting the message more than once, is this the normal behavior of the
> concurrentConsumers config???
> 


-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/concurrentConsumers-basic-question-tp4535789p4537024.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: concurrentConsumers basic question

Posted by preben <pr...@dr.dk>.
If you want multiple consumers on topics you might take a look at virtual
topics. 
My guess is that these can have multiple consumers. Correct me if i'm wrong.

/preben

--
View this message in context: http://camel.465427.n5.nabble.com/concurrentConsumers-basic-question-tp4535789p4536257.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: concurrentConsumers basic question

Posted by rogelio_sevilla1 <ro...@gmail.com>.
You're totally right mr. Travis, just confirmed and also read it on the camel
book 


concurrentConsumers 

Sets the number of consumer threads to use. It’s a good
 idea to increase this for high-volume queues, *but it’s not
  advisable to use more than one concurrent consumer for
 JMS topics, because this will result in multiple copies of
the same message*.


--
View this message in context: http://camel.465427.n5.nabble.com/concurrentConsumers-basic-question-tp4535789p4535971.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: concurrentConsumers basic question

Posted by Travis Klotz <tr...@gmail.com>.
I'm not 100% on this, so someone correct me if I'm wrong.

* concurrentConsumers should only be set on the "from" part of a route.
using a queue in the "to" part of a route is not actually going to consume
any messages.

* You probably should not use concurrentConsumers at all with a topic.  A
topic will route a copy of each message it receives to every consumer
attached to it.  So if you have something like:
from("activemq:topic:topicName?concurrentConsumers=5").to("activemq:queue:queueName");
 You will get 5 copies of each message sent to the topic placed on the
queue.

Travis

You probably do not want to use Concurrent Consumers on a topic.  In
that scenario, each consumer will get a copy of each message sent to the
topic.  Topics do not care if

On Wed, Jun 29, 2011 at 12:50 PM, rogelio_sevilla1 <
rogelio.sevilla1@gmail.com> wrote:

> thanks for the answer Mr. Pham, I've commented my "concurrent configs" on
> my
> spring file and I've done it the way you propose:
>
>
> from("activemq:topic:xmlOrders").to("activemq:accounting?concurrentConsumers=5");
>
>
> Thanks for the advice. However, the  activemq:accounting queue is still
> getting the message more than once, is this the normal behavior of the
> concurrentConsumers config???
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/concurrentConsumers-basic-question-tp4535789p4535904.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: concurrentConsumers basic question

Posted by rogelio_sevilla1 <ro...@gmail.com>.
thanks for the answer Mr. Pham, I've commented my "concurrent configs" on my
spring file and I've done it the way you propose:

from("activemq:topic:xmlOrders").to("activemq:accounting?concurrentConsumers=5"); 


Thanks for the advice. However, the  activemq:accounting queue is still
getting the message more than once, is this the normal behavior of the
concurrentConsumers config???

--
View this message in context: http://camel.465427.n5.nabble.com/concurrentConsumers-basic-question-tp4535789p4535904.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: concurrentConsumers basic question

Posted by Pham Ngoc Hai <pn...@yahoo.com>.
Hi rogelio,
I think you should not have maxConcurrentConsumers on a connection pool.
What you want may be maxConcurrentConsumers on the activemq consumer like:

from("activemq:topic:xmlOrders").to("activemq:accounting?concurrentConsumers=5");
from("activemq:topic:xmlOrders").to("activemq:production");


Regards,
Ngoc Hai


--- On Thu, 6/30/11, rogelio_sevilla1 <ro...@gmail.com> wrote:

> From: rogelio_sevilla1 <ro...@gmail.com>
> Subject: concurrentConsumers basic question
> To: users@camel.apache.org
> Date: Thursday, June 30, 2011, 12:08 AM
> Hello everyone,  sorry if this
> is too basic.
> 
> I'm beginning to use Camel (along with Fuse ESB but that's
> another story) , 
> and i'm doing some basic tests while reading "camel in
> action" (excellent
> book by the way). Anyway, i was trying an activemq
> concurrent example, and i
> configured it like this on my spring file:
> 
> 
> 
>  <bean id="jmsConnectionFactory" 
>    class="org.apache.activemq.ActiveMQConnectionFactory">
>    <property name="brokerURL"
> value="vm://localhost" />
>    
> </bean>
> 
> <bean id="pooledConnectionFactory" 
>    class="org.apache.activemq.pool.PooledConnectionFactory">
>    <property name="maxConnections"
> value="8" />
>    <property name="maximumActive"
> value="500" />
>    <property name="connectionFactory"
> ref="jmsConnectionFactory" />
> </bean>
> 
> <bean id="jmsConfig" 
>    class="org.apache.camel.component.jms.JmsConfiguration">
>    <property name="connectionFactory"
> ref="pooledConnectionFactory"/>
>    <property name="transacted"
> value="false"/>
>  * <property name="maxConcurrentConsumers"
> value="10"/>*
> </bean>
> 
> <bean id="activemq" 
>    
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>     <property name="configuration"
> ref="jmsConfig"/>
> </bean>
> 
> 
> *And I have a simple route doing this:*
> 
> 
> from("activemq:incomingOrders").to("activemq:topic:xmlOrders") 
> 
> 
>          
> from("activemq:topic:xmlOrders").to("activemq:accounting");   
>          
> from("activemq:topic:xmlOrders").to("activemq:production");   
> 
> 
> *Accounting and production have a processos printing
> something like this: *
> 
> Accounting received the order from: dummy.xml
> Production received the order from: dummy.xml
> 
> 
> The problem is that, when I use the *<property
> name="concurrentConsumers"
> value="10"/>*  option  on my spring
> configuration file,  the
> *activemq:accounting* and *activemq:production* are getting
> the message more
> than once (around 7 times each one), and when i use the
> config    
> *<property name="maxConcurrentConsumers"
> value="10"/>*  everything works ok. 
> does concurrentConsumers force the usage of more threads
> even if they are
> not needed??, what's the correct usage of
> concurrentConsumers??
> 
> Sorry if this is too basic, and thanks for your time :-D
> 
> 
> 
> 
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/concurrentConsumers-basic-question-tp4535789p4535789.html
> Sent from the Camel - Users mailing list archive at
> Nabble.com.
>