camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiram Chirino" <hi...@hiramchirino.com>
Subject Re: Processor thread pool
Date Thu, 18 Oct 2007 15:10:29 GMT
Hi Paul, only consumer components that support aync processing will be
able to leverage the async processing that the thread() call does.

Since the whole async processing model is new and optional.. not all
the existing components have been 'upgraded' to take advantage of it.
And the JMS component one of these guys that is still not taking
advantage of the async processing model.

So what happens is that the jms consumer delivers a message to the
processing route, but it does so synchronously.  It will wait for the
exchange to be fully processed, even it's getting processed by a
thread from thread pool.  Since it's waiting, it will not deliver
anymore messages until that thread  from the thread pool is done
processing the exchange.  This is why you only see 1 message getting
processed at a time.

One way to get around this would be to setup routes that look like:
from("activemq:queue:a").to("seda:a");
from("seda:a").thread(5).to("activemq:queue:b");

The seda component does implement an async consumer.  The one down
side to note is that message will be removed from the jms queue once
the message is delivered to the seda:a endpoint.  It does not wait for
the message to get delivered to queue b before acking that it was
received.

Make sense??

On 10/16/07, Paulo Ramos <paulo.ramos@multicert.com> wrote:
>
> I am using Camel 1.1-SNAPSHOT.
> I have tried your example but i have only one message being processed by the
> "Processor" at the same time.
>
> camel-context.xml :
>
> ...
>         <endpoint id="queueA"   uri="activemq:queue:a"/>
>         <endpoint id="queueB"   uri="activemq:queue:b"/>
>
>         <route>
>                 <from uri="queueA" />
>                 <thread coreSize="5" maxSize="15" daemon="false" keepAliveTime="1"
> priority="0" stackSize="5"/>
>                 <bean ref="processar"/>
>                 <!-- <process ref="processar" /> -->
>                 <to uri="queueB" ></to>
>         </route>
> ...
>         <bean id="processar" class="org.apache.camel.example.spring.ProcessarPrc"
> />
>
>
> ProcessarPrc.java :
>
> public class ProcessarPrc implements Processor{
>
>
> public void process(Exchange e) {
>
>         Message in = e.getIn();
>         Mensagem  mesg = in.getBody(Mensagem.class);
>
>
> System.out.println(this.getClass().getSimpleName()+"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"+mesg.getId());
>
>
>         mesg.setProcessado(new Random().nextBoolean());
>         long t;
>         t = System.currentTimeMillis();
>
>         while(System.currentTimeMillis()-t<5000){}
>
>         in.setBody(mesg);
>         System.out.println(this.getClass().getSimpleName()+" - " +
> mesg.toString());
>
> System.out.println(this.getClass().getSimpleName()+"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"+mesg.getId());
>     }
> }
>
> --
> View this message in context: http://www.nabble.com/Processor-thread-pool-tf4627377s22882.html#a13239009
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Mime
View raw message