Thank you very much!

Claus Ibsen-2 wrote:
> 
> On Wed, Aug 19, 2009 at 3:51 AM, Kaver<[email protected]> wrote:
>>
>> Hello.
>>
>> I've a route:
>> from("restlet:http://localhost:9080/sts/request?restletMethod=POST";).process(requestProcessor);
>>
>> I create requestProcessor in Spring and inject it to my RouteBuilder.
>> Should
>> requestProcessor be thread-safe? If there will be several messages from
>> endpoint, there will be several threads performing on one instance
>> requestProcessor (like in servlets), or these events will be quened and
>> will
>> be processed in single thread?
>> --
> 
> You get concurrency by the consumer whether it supports concurrent
> consumers. The HTTP based obviously supports that so the reslet will
> process concurrent incoming requests and thus Camel will route
> concurrently as well.
> 
> So your requestProcessor will be invoked concurrently also. So yes
> design it to be thread safe.
> 
> 
> As its provided by Spring you can let spring provide its lifecycle.
> Spring uses singleton by default. You can change that to prototype so
> a new instance is returned on each request. And then use .processRef
> to refer to by its spring bean id and you get a new instance for each
> request.
> 
> But I suggest to just let processor be thread safe, eg by doing all
> you need inside the process method, without having state on the class
> itself and you should be safe.
> 
> 
>> View this message in context:
>> http://www.nabble.com/Is-Processor-is-thread-safe--tp25036519p25036519.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Is-Processor-is-thread-safe--tp25036519p25038964.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to