camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colin Ruthven <>
Subject Re: Non-Spring Transaction Manager
Date Tue, 24 Mar 2009 13:19:33 GMT
Thanks. That got me further.

Assuming I use JOTM and use it for transaction control within Java, I 
attempted the following applicationContext.xml :

   <context:component-scan base-package="org.apache.camel.spring.produce"/>
   <camel:camelContext id="camel">
  <bean id="jotm" 
  <bean id="jtaTransactionManager" 
       <property name="userTransaction"><ref local="jotm"/></property>

    <bean id="jmsConnectionFactory" 
    <bean id="jmsComponent" 
        <property name="transactionManager"><ref 
        <property name="transacted" value="true"/>
        <property name="connectionFactory"><ref 
local="jmsConnectionFactory"/> </property>

I have a unit test successfully sending and receiving to an ActiveMQ 
broker outside the VM.

To that test I created a JOTM TransactionManager, Transaction then 
prefixed the producer.sendBody() with a begin transaction and followed 
the send with a rollback.
The message still gets sent.

By the looks of stdout Spring is finding the JTA and JOTM is starting.

I'm using Camel 1.6 and ActiveMQ 5.2

What am I missing?


James Strachan wrote:
> 2009/3/23 Colin Ruthven <>:
>> I don't specifically have one in mind.
>> In exploring Camel I found that one can perform the basic messaging
>> functions in Java using Camel API's only but got messy with transactions.
>> My preference would be for Camel to expose a JTA. If that transparently
>> invoked Spring TX that would be fine - analogous to the various components
>> wrapping Spring but not exposing it directly in Java.
> BTW you can ignore the Spring IoC stuff if you like and just use Java
> to wire stuff together and populate JNDI - or use Guice or whatever.
>> What other options exist outside a container (or inside) for transaction
>> support that would work with Camel?
> The JMS component & endpoints relies on the Spring JMS abstractions
> (JmsTemplate and MessageListenerContainer classes) which use Spring
> transactions under the covers. However its pretty trivial to configure
> the JmsComponent to use Spring's JtaTransactionManager then you can do
> whatever you like with JTA and all the JMS endpoints will be
> auto-enlisted in JTA for you.
> However one of the main benefits of the spring transactions support
> (other than the proxy/aop/annotation stuff) is that its trivial to
> switch between XA/JTA and  lightweight transactions (e.g. pure JMS
> transactions or pure JDBC transactions) without the J2EE Transaction
> Manager / JCA / XA overhead.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message