You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Cameleer <ka...@gmail.com> on 2013/12/03 09:52:49 UTC

Re: multicast transaction

For the transaction you need a TransactionManager. For example spring's
JmsTransactionManager.

The multicast component can be a real time saver, because it can process the
nested components in parallel threads. But it is the nature of transaction
managers to register themselves in a ThreadLocal, which in most cases is not
accessible from the threads in a thread pool in which the multicast
component executes your jms tasks. So you can't use multicast.

Anyway, you want to faill all message deliveries if at least one throws an
error, right?
So they must be related to each other. In this case you're not seeking for
performance. 
I mean given that the transaction manager must keep track of all results, so
that it can rollback all deliveries in case an error occured, the tasks of
sending multiple jms messages is not really asynchronously independent.

I would process the complete route in one thread. If you only want the
transaction on the sending side you may split the route with another direct
route, like so:

<bean id="transactionManager"
class="org.springframework.jms.connection.JmsTransactionManager">
	<property name="connectionFactory" ref="activemqConnectionFactory"/>
</bean>
<bean id="PROPAGATION_REQUIRED"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
	<property name="transactionManager" ref="transactionManager"/>
	<property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>
</bean>

<camelContext xmlns="http://camel.apache.org/schema/spring">
	<route>
		<from uri="direct:a"/>
		<to uri="direct:sendjms"/>
	</route>

	<route>
		<from uri="direct:sendjms"/>
		<transacted ref="PROPAGATION_REQUIRED"/>
		<to uri="activemq:queue:runQueue"/>
		<to uri="activemq:queue:consumeQueue"/>
	</route>
</camelContext>




--
View this message in context: http://camel.465427.n5.nabble.com/multicast-transaction-tp474719p5744224.html
Sent from the Camel - Users mailing list archive at Nabble.com.