1

We have an issue in the application that the jms message commit on the ibm mq takes hours to complete which inturn causing the log space filling up in ibm mq and also JVM hung issues on the application side. To resolve this, I tried implementing the transaction timeout on the route, jms component etc. But nothing looks to be working.

There are 3 routes in the application

  1. To Read message (Start route)
  2. Deliver/Send message
  3. Error Route (sending to error queue)

The Route definitions are below,

Input/Consumer Route

public class InputRoute extends SpringRouteBuilder {

    @Override
    public void configure() throws Exception {
    from("wmqInConsumer:{{mq.inputQueue}}?concurrentConsumers={{num.consumers}}&maxConcurrentConsumers={{max.num.consumers}}&defaultTaskExecutorType=ThreadPool&preserveMessageQos=true").routeId("input-route").setHeader("Message_Key").method("headerEnricher", "setKey").inOnly("direct:deliver-normal-route-1");
    }
}

Deliver Route

public class DeliverRoute extends SpringRouteBuilder {

    @Override
    public void configure() throws Exception {

        from("direct:deliver-normal-route-1").transacted("PROPAGATION_REQUIRES_NEW").inOnly("direct:deliver-route-2");

        from("direct:deliver-route-2").process("myServicesProcessor").split()
                .method("messageSplitterBean", "splitMessage").shareUnitOfWork().stopOnException()
                .toD("wmqDeliverJms:${headers.Deliver}?preserveMessageQos=true");
    }
}

Error Route

public class ErrorRoute extends SpringRouteBuilder {

    @Override
    public void configure() throws Exception {

        from("direct:errorChannelRoute").transacted("PROPAGATION_REQUIRES_NEW").inOnly("direct:errorChannelRoute-1");

        from("direct:errorChannelRoute-1").process("errorServicesProcessor").split()
                .method("messageSplitterBean", "splitErrorMessage").shareUnitOfWork().stopOnException()
                .toD("wmqDeliverJms:${headers.Deliver}?preserveMessageQos=true");

    }
}

Here the transaction timeouts I tried based on the Camel documentation. But It's not working and I don't see transaction timeout happening in the trace logs too. Also, not sure what will happen to the message if the timeout occurs. Will it go to error queues or full rollback for a retry??

On Input Route, transactionTimeout=10

from("wmqInConsumer:{{mq.inputQueue}}?concurrentConsumers={{num.consumers}}&maxConcurrentConsumers={{max.num.consumers}}&defaultTaskExecutorType=ThreadPool&preserveMessageQos=true&transactionTimeout=10").routeId("input-route").setHeader("Message_Key").method("headerEnricher", "setKey").inOnly("direct:deliver-normal-route-1");

On Input Route JMS Component,

<bean id="wmqInConsumer" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory" ref="myConnectionFactory" />
        <property name="transacted" value="true" />
        <property name="transactionTimeout" value="30"></property> -->
    </bean>

On Deliver Route JMS Component,

<bean id="wmqDeliverJms" class="org.apache.camel.component.jms.JmsComponent">
        <property name="connectionFactory" ref="myConnectionFactory" />
        <property name="destinationResolver" ref="myJmsDestinationResolver" />
        <property name="transacted" value="true" />
        <property name="transactionTimeout" value="30"></property>
    </bean>
JoshMc
  • 10,239
  • 2
  • 19
  • 38
Selvakumar
  • 189
  • 1
  • 13
  • In docs is `transactionTimeout: The timeout value of the transaction (in seconds), if using transacted mode.` So I would try to set transacted mode with `&transacted=true&transactionTimeout=10` – Bedla Jul 18 '18 at 19:23
  • Yes, If you look at the options I tried, I pretty much tried all options based on the Camel documentation. But It's not working and I don't transaction see timeout happening in the trace logs too. Also, not sure what will happen to the message if the timeout occurs. Will it go to error queues or full rollback for a retry?? – Selvakumar Jul 18 '18 at 19:41
  • Now I see it. According [this really old thread](http://camel.465427.n5.nabble.com/configure-transaction-timeout-in-camel-route-td5718339.html) the timeout option is available only if using JTA transaction. Sorry for confusion, I have used jms component only with JtaTransactionManager, so cannot tell, if something changed according this option. In JTA environment is `javax.transaction.RollbackException` thrown, which causes full rollback to queue, but I dont know the behavior for Spring managed transaction. – Bedla Jul 18 '18 at 20:03
  • Thanks for sharing the link. It clearly says timeout is not available for JMSTrasaction. I will have to wait for someone from Camel/Spring team to confirm this. – Selvakumar Jul 18 '18 at 20:08

0 Answers0