You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by shlomi java <sh...@gmail.com> on 2012/02/14 11:21:14 UTC

Threads not consuming in parallel

hi Forum,

I'm trying to do a simple route, consuming from a JMS queue and handling
several messages in parallel by some Bean.

It's a simple <from uri="activemq:queue:MyQueue"/><threads
executorServiceRef="myPool"><bean beanType="org.Executer" /></threads>
route. camel-context.xml is attached.

Well, it does not work...
The queue has several messages in it, debugging in eclipse I see some JMS
Consumers, but only a single "Camel Cool" thread (that's the name I give to
the threads in the XML), causing the messages to be processed one by one.

What's wrong? where can be the problem?
Is it the ActiveMQ broker? JMS configuration?

I'm using ActiveMQ 5.5.1, Camel 2.8.1. Java 6, on a 32 bit Windows 7
computer.

thanks for any help,
ShlomiJ

Re: Threads not consuming in parallel

Posted by shlomi java <sh...@gmail.com>.
thanks, great.

I'll have to upgrade to 2.9, though, as the documentation states the
asyncConsumer property does not yet exist in 2.8.1.

On Wed, Feb 15, 2012 at 3:25 PM, Claus Ibsen-2 [via Camel] <
ml-node+s465427n5486036h30@n5.nabble.com> wrote:

> On Tue, Feb 14, 2012 at 3:23 PM, ShlomiJ <[hidden email]<http://user/SendEmail.jtp?type=node&node=5486036&i=0>>
> wrote:
>
> > *Solved!* sort of...
> >
> > The problem was that the JMS queue got filled with messages *before* any
> > consumer was available.
> >
> > When the consumers were finally started, by initiating the to:activemq
> > endpoint, all existing messages in the JMS queue were assigned to a
> *single
> > consumer!*
> >
> > That caused the _appearance_ of a sequential processing, while actually
> > *new* messages WERE distributed among consumers evenly and were passed
> in
> > parallel, each to a different thread in the pool.
> >
> > to Willem.Jiang:
> >
> > Willem.Jiang wrote
> >> Did you have a change to set the activemq endpoint option of
> >> concurrentConsumers like this?
> >>
> >>
> > I've tried it, but it simply overrides the corresponding
> JmsConfiguration's
> > properties from the camel-context.xml. It did not changed anything.
> >
> > Now I realize that a consumer is attached to a thread from the pool,
> until
> > that thread is finished.
> > Why?
> >
> > *Can't a consumer simply pass a message to a thread from the pool and be
> > done with it, without having to wait for the thread to finish it run?*
> >
>
> On the JMS endpoint you need to set asyncConsumer=true.
> http://camel.apache.org/jms
>
>
>
>
> > any thoughts?
> >
> > ShlomiJ
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Threads-not-consuming-in-parallel-tp5482274p5482568.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: [hidden email]<http://user/SendEmail.jtp?type=node&node=5486036&i=1>
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/Threads-not-consuming-in-parallel-tp5482274p5486036.html
>  To unsubscribe from Threads not consuming in parallel, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5482274&code=c2hsb21pamF2YUBnbWFpbC5jb218NTQ4MjI3NHwyMDk5Nzg4MjQ1>
> .
> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>

Re: Threads not consuming in parallel

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Feb 14, 2012 at 3:23 PM, ShlomiJ <sh...@gmail.com> wrote:
> *Solved!* sort of...
>
> The problem was that the JMS queue got filled with messages *before* any
> consumer was available.
>
> When the consumers were finally started, by initiating the to:activemq
> endpoint, all existing messages in the JMS queue were assigned to a *single
> consumer!*
>
> That caused the _appearance_ of a sequential processing, while actually
> *new* messages WERE distributed among consumers evenly and were passed in
> parallel, each to a different thread in the pool.
>
> to Willem.Jiang:
>
> Willem.Jiang wrote
>> Did you have a change to set the activemq endpoint option of
>> concurrentConsumers like this?
>>
>>
> I've tried it, but it simply overrides the corresponding JmsConfiguration's
> properties from the camel-context.xml. It did not changed anything.
>
> Now I realize that a consumer is attached to a thread from the pool, until
> that thread is finished.
> Why?
>
> *Can't a consumer simply pass a message to a thread from the pool and be
> done with it, without having to wait for the thread to finish it run?*
>

On the JMS endpoint you need to set asyncConsumer=true.
http://camel.apache.org/jms




> any thoughts?
>
> ShlomiJ
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Threads-not-consuming-in-parallel-tp5482274p5482568.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.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Threads not consuming in parallel

Posted by ShlomiJ <sh...@gmail.com>.
*Solved!* sort of...

The problem was that the JMS queue got filled with messages *before* any
consumer was available.

When the consumers were finally started, by initiating the to:activemq
endpoint, all existing messages in the JMS queue were assigned to a *single
consumer!*

That caused the _appearance_ of a sequential processing, while actually
*new* messages WERE distributed among consumers evenly and were passed in
parallel, each to a different thread in the pool.

to Willem.Jiang:

Willem.Jiang wrote
> Did you have a change to set the activemq endpoint option of 
> concurrentConsumers like this? 
> 
> 
I've tried it, but it simply overrides the corresponding JmsConfiguration's
properties from the camel-context.xml. It did not changed anything.

Now I realize that a consumer is attached to a thread from the pool, until
that thread is finished.
Why?

*Can't a consumer simply pass a message to a thread from the pool and be
done with it, without having to wait for the thread to finish it run?*

any thoughts?

ShlomiJ



--
View this message in context: http://camel.465427.n5.nabble.com/Threads-not-consuming-in-parallel-tp5482274p5482568.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Threads not consuming in parallel

Posted by Willem Jiang <wi...@gmail.com>.
Hi 

Did you have a change to set the activemq endpoint option of 
concurrentConsumers like this?

<camel:from uri="activemq:queue:MyQueue?concurrentConsumers=10"/>

On Tue Feb 14 18:21:14 2012, shlomi java wrote:
> hi Forum,
>
> I'm trying to do a simple route, consuming from a JMS queue and 
> handling several messages in parallel by some Bean.
>
> It's a simple <from uri="activemq:queue:MyQueue"/><threads 
> executorServiceRef="myPool"><bean beanType="org.Executer" /></threads> 
> route. camel-context.xml is attached.
>
> Well, it does not work...
> The queue has several messages in it, debugging in eclipse I see some 
> JMS Consumers, but only a single "Camel Cool" thread (that's the name 
> I give to the threads in the XML), causing the messages to be 
> processed one by one.
>
> What's wrong? where can be the problem?
> Is it the ActiveMQ broker? JMS configuration?
>
> I'm using ActiveMQ 5.5.1, Camel 2.8.1. Java 6, on a 32 bit Windows 7 
> computer.
>
> thanks for any help,
> ShlomiJ



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang