1 Reply Latest reply on Jun 28, 2014 4:38 AM by davsclaus

    JBoss Fuse 6.1 Transaction not rolled back for jdbc jms

    atul.k

      Hi,

       

      I am new to JBoss Fuse. I am trying to create a transaction where records are picked from a db and passed to a amq queue. A flag should be updated once the message is successfully posted to AMQ. If DB goes down before message is sent to AMQ, the transaction is rolled back as expected. However, if DB goes down after posting to AMQ, but before updating flag, the transaction does not roll back. Can someone please suggest what am doing wrong.

       

      <?xml version="1.0" encoding="UTF-8"?>
      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/blueprint"
      xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
      xsi:schemaLocation="
      http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
      http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

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


      <bean id="auditEventNotifier" class="com.bmg.esb.im2capture.utility.AuditEventNotifier">
      </bean>

      <bean id="dataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
        <property name="url" value="jdbc:mysql://localhost:3306/test" />
        <property name="user" value="root" />
        <property name="password" value="root" />
      </bean>

      <bean id="sql" class="org.apache.camel.component.sql.SqlComponent">
        <property name="dataSource" ref="dataSource" />
      </bean>

      <bean id="recordmapping" class="com.bmg.esb.im2capture.transformer.Recordmapping" />
      <bean id="dbtojson" class="com.bmg.esb.im2capture.transformer.DBToJSon" />

      <bean id="activemqs" class="org.apache.camel.component.jms.JmsComponent">
        <property name="configuration" ref="jmsConfig" />
      </bean>

      <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
        <property name="connectionFactory" ref="jmsConnectionFactory" />
        <property name="transactionManager" ref="jmsTransactionManager" />
        <property name="transacted" value="true" />
        <property name="cacheLevelName" value="CACHE_CONNECTION" />
      </bean>

      <bean id="jmsTransactionManager"
        class="org.springframework.jms.connection.JmsTransactionManager">
        <property name="connectionFactory" ref="jmsConnectionFactory" />
      </bean>

      <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://localhost:61616" />
        <property name="userName" value="admin" />
        <property name="password" value="admin" />
      </bean>

      <camelContext id="blueprintContext" trace="false"
        xmlns="http://camel.apache.org/schema/blueprint">
        <propertyPlaceholder id="placeholder" location="classpath:sql.properties" />

        <!-- <camel:onException id="BMGExceptionHandler"> <camel:exception>java.lang.Exception</camel:exception>
         <camel:handled> <camel:constant>true</camel:constant> </camel:handled> <camel:log
         message="Trying to handle the exception"></camel:log> </camel:onException> -->
        <route id="iMaestro-Capture">
         <from uri="sql:{{sql.selectSong}}?consumer.onConsume={{sql.markSong}}" />
         <transacted ref="required" />
         <camel:bean ref="recordmapping" method="changeFormat" />
         <!-- <camel:log message="Before calling the DBToJSON class"></camel:log> -->
         <camel:bean ref="dbtojson" method="convertDbToJSon" />
         <camel:delay>
          <constant>10000</constant>
         </camel:delay>
         <!-- <camel:log message="Called the DBToJSON class"></camel:log> -->
         <camel:convertBodyTo type="String"></camel:convertBodyTo>
         <to uri="activemqs:queue:testQueues" />
         <!-- <log message="The body of JSon::${body}" /> -->
         <to uri="sql:{{sql.updateSongFlag}}" />
         <!-- <to uri="activemqs:queue:CaptureTestQueues?concurrentConsumers=10" /> -->
         <!-- <log message="Reached the Capture queue" /> -->
        </route>
      </camelContext>
      </blueprint>