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" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/smx/TransactionManager" />
   </bean>

JMS connection factory is good too

<bean id="connectionFactory" class="org.jencks.amqpool.XaPooledConnectionFactory">
       <constructor-arg value="${jms.broker.url}"/>

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

Next step I specify my db2 datasource

   <bean id="dataSource"
       class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" /> <property name="url" value="jdbc:db2://${db.host}:${db.port}/${db.name}" />
       <property name="username" value="${db.username}" />
       <property name="password" value="${db.password}" />
       <property name="connectionProperties">
           <props>
               <prop key="currentSchema">${db.schema}</prop>
           </props>
       </property>
   </bean>

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

Next step is sessionFactory

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

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

looks normal

Last step is to specify policy - taken from sample

<bean id="required" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
       <property name="template" ref="PROPAGATION_REQUIRED"/>
   </bean>

   <bean id="PROPAGATION_REQUIRED"
       class="org.springframework.transaction.support.TransactionTemplate">
       <property name="transactionManager" ref="txTransactionManager"/>
   </bean>

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"/>

           <setBody><el><![CDATA[<message>test</message>]]></el></setBody>

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

       </route>

Problem
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
__________
Pavel
  • Server Stops working ratik
    • Need a sample of using XA transaction inside camel s... Pavel Khozhainov

Reply via email to