Camel JMS XA Client

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Camel JMS XA Client

Hi All,

Requirement - Transacted route, we have to consume messages from MQ queue. Multiple resources involved, hence use XA transactions.

Environment - Jboss Fuse 6.2.1, JDK 8, MQ

I use following to create the JMSComponent in blueprint and everything works fine as expected.

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

    <bean id="WMQConfig" class="org.apache.camel.component.jms.JmsConfiguration">
        <property name="connectionFactory" ref="FuseWmqXaConnectionFactory" />
        <property name="transacted" value="false" />
        <property name="transactionManager" ref="platformTxManager" />
        <property name="maxConcurrentConsumers" value="5" />
        <property name="cacheLevelName" value="CACHE_NONE" />

    <bean id="FuseWmqXaConnectionFactory" class="org.apache.activemq.jms.pool.JcaPooledConnectionFactory">
        <property name="connectionFactory" ref="WMQConnectionFactory"/>
        <property name="transactionManager" ref="recoverableTxManager"/>
        <property name="maxConnections" value="1"/>
        <property name="name" value="wmq" />

    <bean id="WMQConnectionFactory" class="">
        <property name="hostName" value="hostname" />
        <property name="port" value="1414" />
        <property name="queueManager" value="QUEUE.MANAGER" />
        <property name="channel" value="SYSTEM.ADMIN.SVRCONN" />
        <property name="transportType" value="1" />

With respect to above configuration I created a custom bean that extends from JMSComponent and tried to create JMS XA connection factory

1) defined a custom bean that extends from JMSComponent
2) Inside this bean I am instantiating and wiring all above components

The XA connection works fine when I send the message to MQ, however when I am using the same connection to consume message from MQ it produces following warnings/errors in log file,

PooledSession                    | 189 - org.apache.activemq.activemq-osgi - 5.11.0.redhat-621107 | Caught exception trying close() when putting session back into the pool, will invalidate. JMSCC0020: This session is closed.
n  | An application called a method that must not be used after the session is closed.
n  | Ensure that the session is not closed before calling the method. JMSCC0020: This session is closed.
An application called a method that must not be used after the session is closed.
Ensure that the session is not closed before calling the method.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_25]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance([:1.8.0_25]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance([:1.8.0_25]
        at java.lang.reflect.Constructor.newInstance([:1.8.0_25]
        at org.apache.activemq.jms.pool.PooledSession.close([189:org.apache.activemq.activemq-osgi:5.11.0.redhat-621107]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.clearResources([215:org.apache.servicemix.bundles.spring-jms:3.2.12.RELEASE_2]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$[215:org.apache.servicemix.bundles.spring-jms:3.2.12.RELEASE_2]
        at java.util.concurrent.ThreadPoolExecutor.runWorker([:1.8.0_25]
        at java.util.concurrent.ThreadPoolExecutor$[:1.8.0_25]

Appreciate any help to resolve this issue.

- Pravin