How to add the transaction timeout for Apache Camel route with IBM MQ?

1.1k Views Asked by At

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>
0

There are 0 best solutions below