activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pavel Khozhainov" <>
Subject Need a sample of using XA transaction inside camel script with Servicemix
Date Thu, 09 Apr 2009 08:34:51 GMT
Hi all

I need to
1. receive jms
2. update db
3. send jms
inside one XA transaction possible in one route.

Transaction manager is taken form  Servicemix jndi:
It was Jenks tm and it works with XA transactions

    <bean id="txTransactionManager" 
        <property name="jndiName" 
value="java:comp/env/smx/TransactionManager" />

JMS connection factory is good too

    <bean id="connectionFactory" 
        <constructor-arg value="${}"/>

        <property name="maxConnections" value="8" />
        <property name="transactionManager" ref="txTransactionManager" />

Next step I specify my db2 datasource

    <bean id="dataSource"
        <property name="driverClassName" value="" 
        <property name="url" 
value="jdbc:db2://${}:${db.port}/${}" />
        <property name="username" value="${db.username}" />
        <property name="password" value="${db.password}" />
        <property name="connectionProperties">
                <prop key="currentSchema">${db.schema}</prop>

I can not create real DB2XADataSource because it was DB2JccDataSource not 
(is the problem here?)

Next step is sessionFactory

    <bean id="sessionFactory" 

        <property name="jtaTransactionManager" ref="txTransactionManager"/>
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
... mappings
        <property name="hibernateProperties">
    ... props

looks normal

Last step is to specify policy - taken from sample

    <bean id="required" 
        <property name="template" ref="PROPAGATION_REQUIRED"/>

        <property name="transactionManager" ref="txTransactionManager"/>

I write my camel route i following way

        <route errorHandlerRef="deadLetterErrorHandler">

            <from uri="jms:queue:test.tran.01"/>

            <policy ref="required"/>

            <to uri = "bean:rendererBean?methodName=process"/>


            <to uri = "jms:queue:test.tran.02"/>


When process() method of my bean is called xa transaction was not open.
I expect that <policy step will open it but this was not happen.

Please tell me what to do
- must I specify "xa" somehere as I do with jms eip component?

It is a good idea to add camel xa sample to set of samples

View raw message