You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jb3 <je...@yahoo.ca> on 2014/11/27 13:51:27 UTC

Messages consumed from JmsComponent not marked as transacted

Hi,

I am using Camel 2.10.4 (long overdue for an upgrade ;) )

I have configured a JmsComponent in xml to be transacted. However, when I
run the unit test below, the exchanges are marked as *not* being transacted.
If I add ".transacted()" to the java routing code, then
exchange.isTransacted() returns true. I was hoping though, to just configure
the JmsComponent to be transacted, and then all Exchanges coming from it to
be transacted.

Any help is greatly appreciated. Thanks!

Here is my code:

@RunWith(CamelSpringJUnit4ClassRunner.class)
@ContextConfiguration(locations =
"classpath:/org/mycode/transaction-test.xml")

public class TransactedTest {

  @Test
  public void  testTransactedness() throws InterruptedException {
    Thread.sleep(60000);
  }

  public final static class TestRouteBuilder extends RouteBuilder {
    @Override
    public void configure() throws Exception {
      from("ibmmq:queue:test.q")  //if I add *transacted()* here, the
exchanges are marked as transacted
        .bean(new Tracker());
    }
  }

  public final static class Tracker implements Processor {
    @Override
    public void process(Exchange exchange) throws Exception {
      System.out.println("Is exchange transacted: " +
exchange.isTransacted()); // always prints false
    }
  }

}

transaction-test.xml:
<?xml....
<beans...

<bean id="routeBuilder" class="org.mycode.TransactedTest.TestRouteBuilder"
/>
<camelContext id="camelTestContext"
xmlns="http://camel.apache.org/schema/spring">
  <routeBuilder ref="routeBuilder" />
</camelContext>

<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent">
  <property name="connectionFactory">
    <bean
class="org.springframework.jms.connection.CachingConnectionFactory">
      <property name="targetConnectionFactory" ref="mqConnection" />
      <property name="sessionCacheSize" value="5" />
    <bean>
  </property>
  <property name="transactionManager" ref="mqTransactionManager" />
  <property name="transacted" value="true" />
  <property name="testConnectionOnStartup" value="true" />
  <property name="lazyCreateTransactionManager" value="false" />
  <property name="acceptMessagesWhileStopping" value="true" />
</bean>

<bean id="mqConnection" class="com.ibm.mq.jms.MQConnectionFactory'>
  <property name="channel" value="SYSTEM.AUTO.SVRCONN" />
  <property name="transportType" value="1" />
  <property name="hostName" value="XXXXXXX" />
  <property name="port" value="XXXX" />
  <property name="queueManager" value="XXXXXXXX" />
  <property name="temporaryModel" value="XXXXXXXX" />
  <property name="tempQPrefix" value="XXXXXXXX" />
</bean>

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



--
View this message in context: http://camel.465427.n5.nabble.com/Messages-consumed-from-JmsComponent-not-marked-as-transacted-tp5759702.html
Sent from the Camel - Users mailing list archive at Nabble.com.