transactions - Does ActiveMQ support multiple transactional consumers? -
i developing osgi bundles in servicemix consume same queue of activemq.
i need sure message dequeued if every thing goes fine don't lose message. used camel transactional client. manged implement following tutorial http://camel.apache.org/transactional-client.html
however, problem when deploy many bundles consuming same queue, 1 consumer working @ same time.
what should enable parallel transactional consumption in activemq ?
thanks in advance.
regards,
this implementation (just copied tutorial):
the camel route:
<route> <from uri="activemq:queue:foo"/> <transacted ref="required"/> <process ref="myprocessor"/> <to uri="activemq:queue:bar"/> </route> the 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&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 jms consumer/producer transacted --> <property name="transacted" value="true"/> <!-- setup transaction manager use --> <!-- if not provided camel automatic use jmstransactionmanager, if instance use jta transaction manager must configure --> <property name="transactionmanager" ref="jmstransactionmanager"/> </bean>
i found solution here http://activemq.2283324.n4.nabble.com/blocking-transactions-td2354801.html;cid=1431937246689-831.
the problem due prefetch limit. recommended put 0 when there multiple consumers if aren't transactional.
so had change camel route adding ?destination.consumer.prefetchsize=0 way :
<route> <from uri="activemq:queue:foo?destination.consumer.prefetchsize=0"/> <transacted ref="required"/> <process ref="myprocessor"/> <to uri="activemq:queue:bar"/> </route>
Comments
Post a Comment