You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2009/12/01 06:26:53 UTC

Re: concurrentconsumers thread safe?

Its all about how you have implemented your asyncMDPCallback bean.
You can implemented it badly so its not threadsafe. And you can
implemented it correct so its threadsafe.

The Camel pieces are threadsafe and supports concurrency out of the box.

A rule of thumb in your bean is to not have any state, e.g. dont have
any class fields in your bean.



On Mon, Nov 30, 2009 at 10:44 PM, skt99 <sk...@yahoo.com> wrote:
>
> It appears my configuration did not get copied properly..I am sending it
> again...thanks.
>
>  <camel:camelContext id="camelContext">
>        <camel:route id="response">
>            <camel:from uri="jms:queue:dev.callback.Response"/>
>            <camel:to uri="bean:asyncMDPCallback"/>
>        </camel:route>
>    </camel:camelContext>
>
>  <bean id="workflowflowExceptionTaskExecutor"
>
> class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
>        <property name="corePoolSize" value="5"/>
>        <property name="maxPoolSize" value="10"/>
>        <property name="queueCapacity" value="25"/>
> </bean>
>
>  <bean id="jmsConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">
>        <property name="connectionFactory"
> ref="jcaPooledConnectionFactory"/>
>        <property name="transactionManager" ref="transactionManager"/>
>        <property name="transacted" value="true"/>
>        <property name="taskExecutor" ref="workflowCallbackTaskExecutor"/>
>        <property name="concurrentConsumers" value="5"/>
>        <property name="maxConcurrentConsumers" value="10" />
>    </bean>
>
>  <bean id="jms"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>        <property name="configuration" ref="jmsConfig"/>
>  </bean>
>
> Appreciate any help.
>
>
> skt99 wrote:
>>
>> Hi,
>>    I have this configuration - The Spring context is loaded only once on
>> app startup. An MDP asyncMDPCallback configured as a singleton using
>> Spring, is setup to consume messages.
>>
>>   <camel:camelContext id="camelContext">
>>         <camel:route id="response">
>>             <camel:from uri="jms:queue:dev.callback.Response" />
>>             <camel:to uri="bean:asyncMDPCallback" />
>>         </camel:route>
>>     </camel:camelContext>
>>
>>  <bean id="workflowflowExceptionTaskExecutor"
>> class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
>>         <property name="corePoolSize" value="5" />
>>         <property name="maxPoolSize" value="10" />
>>         <property name="queueCapacity" value="25" />
>> </bean>
>>
>>  <bean id="jmsConfig"
>> class="org.apache.camel.component.jms.JmsConfiguration">
>>         <property name="connectionFactory"
>> ref="jcaPooledConnectionFactory" />
>>         <property name="transactionManager" ref="transactionManager" />
>>         <property name="transacted" value="true" />
>>         <property name="taskExecutor" ref="workflowCallbackTaskExecutor"
>> />
>>         <property name="concurrentConsumers" value="5" />
>>         <property name="maxConcurrentConsumers" value="10" />
>>     </bean>
>>
>>  <bean id="jms"
>> class="org.apache.activemq.camel.component.ActiveMQComponent">
>>         <property name="configuration" ref="jmsConfig" />
>>  </bean>
>>
>> Is this setup for concurrentConsumers using ThreadPoolTaskExecutor
>> thread-safe by default, or do I need to handle it in my app? Appreciate
>> any help.
>>
>
> --
> View this message in context: http://old.nabble.com/concurrentconsumers-thread-safe--tp26582427p26582486.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus