Does ActiveMQ support multiple transactional consumers?

I am developing OSGI packages in ServiceMix for use from a single ActiveMQ queue.

I need to make sure that the message is deleted only if everything goes well so that I don't lose this message. So I used a client-side transactional client. I managed to implement it by following this tutorial http://camel.apache.org/transactional-client.html

However, the problem is that when deploying many packages consuming the same queue, I only get one user working at a time.

What to do to enable concurrent transactional consumption in ActiveMQ?

Thanks in advance.

Hello,


This is my implementation (just copied from the tutorial):

Camel route:

   <route>
      <from uri="activemq:queue:foo"/>
      <transacted ref="required"/>
      <process ref="myProcessor"/>
      <to uri="activemq:queue:bar"/>
    </route>

      

Spring context:

<!-- setup JMS connection factory -->
<bean id="poolConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory">
    <property name="maxConnections" value="8"/>
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
</bean>

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
</bean>

<!-- setup spring jms TX manager -->
<bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
    <property name="connectionFactory" ref="poolConnectionFactory"/>
</bean>

<!-- define our activemq component -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="connectionFactory" ref="poolConnectionFactory"/>
    <!-- define the jms consumer/producer as transacted -->
    <property name="transacted" value="true"/>
    <!-- setup the transaction manager to use -->
    <!-- if not provided then Camel will automatic use a JmsTransactionManager, however if you
         for instance use a JTA transaction manager then you must configure it -->
    <property name="transactionManager" ref="jmsTransactionManager"/>
</bean>

      

+3


source to share


2 answers


Finally I found a solution here http://activemq.2283324.n4.nabble.com/Blocking-transactions-td2354801.html;cid=1431937246689-831 .

The problem is with the prefetch prefix. It is recommended that you specify 0 when there are multiple consumers, even if they are not transactional.



So, I had to change the camel route by adding ? destination.consumer.prefetchSize = 0 as follows:

<route> 
<from uri="activemq:queue:foo?destination.consumer.prefetchSize=0"/>
<transacted ref="required"/> <process ref="myProcessor"/>
<to uri="activemq:queue:bar"/>
</route>

      

+2


source


Concurrent users with ActiveMQ JMS are possible.



<bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="pooledConnectionFactory" />
    <property name="transacted" value="true" />
    <property name="concurrentConsumers" value="10" />
    <property name="deliveryPersistent" value="true" />
    <property name="requestTimeout" value="20000" />
    <property name="cacheLevelName"  value="CACHE_CONSUMER" />
</bean>

      

0


source







All Articles