On Wed, Jul 25, 2012 at 6:40 AM, wantastic <wan....@barclays.com> wrote: > Hello all, > > I am a beginner of Camel and trying to figure out how to create route > properly. > What I'm trying to do is pretty simple. I have a JMS queue listener which > takes message one by one. Then this message will be logged by WireTap and > gets thrown into a threadpool(a pool of worker threads) to be processed. My > first approach was like this: > <camelContext --> > <route> > <threadPool id="myThreadPool" threadName="MyThread" poolSize="10" > maxPoolSize="20" maxQueueSize="1000" /> > <threadPool id="dataLoggerPool" threadName="DataLogger" poolSize="1" > maxPoolSize="1" maxQueueSize="1000" /> > > <from uri="pns-jms:queue:blahblah" /> > <wireTap uri="dataLogger" executorServiceRef="dataLoggerPool"/> > <threads executorServiceRef="myThreadPool"> > <to uri="myValidationProcess" /> > <to uri="myConvertProcess" /> > </threads> > </camelContext> > > However, this turned out to be a wrong implementation since I realized that > messages are not being distributed to multiple threads concurrently. For > example, if I'm doing "Thread.currentThread.sleep(3000)" inside > myConvertProcess, I see threads are being invoked one at a time, not 10 > threads at the same time. In order to solve this problem, I had to use SEDA > to send message to the threadpool asynchronously. So my second > implementation came out like this: > > <route> > <from uri="pns-jms:queue:blahblah" /> > <to uri="seda:processMsg?size=1000;blockWhenFull=true" /> > </route> > <route> > <from uri="seda:processMsg" /> > <threads executorServiceRef="myThreadPool"> > <to uri="myValidationProcess" /> > <to uri="myConvertProcess" /> > </threads> > </route> > > This seems to be working, however, I get two blocking queues, SEDA and > threadpool, which is not so desirable. Therefore, I decided to go with > SEDA's concurrentConsumers. > > <route> > <from uri="pns-jms:queue:blahblah" /> > <to uri="seda:processMsg?size=1000;blockWhenFull=true" /> > </route> > <route> > <from uri="seda:processMsg?concurrentConsumers=10" /> > <to uri="myValidationProcess" /> > <to uri="myConvertProcess" /> > </route> > > This seems to be working okay but I came to another question: What if the > seda queue is full? Will SEDA block from queue to get message when its queue > is full?
It's a typical issue of the Queue, you can use the throttler to do the flow control work. [1]http://camel.apache.org/throttler.html > Does anyone have a better suggestion for implementation? It is a simple > model: get message, throw it into a threadpool to be picked up by a worker > thread to process it. Yes, that is the simpler implementation of SEDA. > > If anyone can give feedback on this, I will be very grateful. > > Thank you, > Wan > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Question-regarding-SEDA-threadpool-tp5716431.html > Sent from the Camel - Users mailing list archive at Nabble.com.