You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by maherm <m_...@hotmail.com> on 2012/08/16 15:05:50 UTC

JMS Transactions with ActiveMQ

Since adding JMS transaction support to our camel / activemq routes I've
noticed a lot of "transport interrupted" and "transport resumed" log
messages being outputted from our application. Is this change in behavior to
be expected? Does the JMS connection handling change once a
TransactionManager has been introduced? Are the ActiveMQ connections or
sessions dropped and reopened periodically, or after a period of inactivity? 

The application itself appears to work fine; the JMS messages are still
processed successfully and when a transaction is rolled back then the
message isn't lost. However we have a monitoring system monitoring the
application's log files, in particular for any connection errors between the
application and the activemq broker. This leads to a lot of alarms being
raised.

Im using Camel Version: 2.10.0, ActiveMQ: 5.5.1 and Spring: 3.1.0

Thanks in advance for any help.

Below is the spring / activemq configuration we're using:

  <bean id="activemqtx"
class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="configuration" ref="txJmsConfiguration"/>
    <property name="transactionManager" ref="jmsTransactionManager"/>
  </bean>

  
  <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="configuration" ref="ntxJmsConfiguration"/>
  </bean>

  <bean id="amqPooledConnectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory"
destroy-method="stop">
    <property name="maxConnections" value="5"/>
    <property name="connectionFactory" ref="amqConnectionFactory"/>
  </bean>

  <bean id="amqConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${activemq.brokerURL}"/>
    <property name="userName" value="${activemq.username}"/>
    <property name="password" value="${activemq.password}"/>
    <property name="exceptionListener" ref="jmsExceptionListener"/>
    <property name="transportListener" ref="jmsTransportListener"/>
    <property name="redeliveryPolicy" ref="redeliveryPolicy"/>
  </bean>

  <bean id="jmsExceptionListener" class="..JmsExceptionListener"/>

  <bean id="jmsTransportListener" class=".JmsTransportListener"/>

  <bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
    <property name="backOffMultiplier" value="2"/>
    <property name="collisionAvoidancePercent" value="15"/>
    <property name="initialRedeliveryDelay" value="5000"/>
    <property name="maximumRedeliveries" value="2"/>
    <property name="useCollisionAvoidance" value="false"/>
    <property name="maximumRedeliveryDelay" value="5000"/>
    <property name="redeliveryDelay" value="5000"/>
    <property name="useExponentialBackOff" value="false"/>
  </bean>

  <bean id="abstractJmsConfiguration" abstract="true"
class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="connectionFactory" ref="amqPooledConnectionFactory"/>
    <property name="exceptionListener" ref="jmsExceptionListener"/>
  </bean>

  <bean id="txJmsConfiguration" parent="abstractJmsConfiguration"
class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="transacted" value="true"/>
    <property name="cacheLevelName" value="CACHE_CONSUMER"/>
    <property name="transactionTimeout" value="60000"/>
  </bean>

  <bean id="ntxJmsConfiguration" parent="abstractJmsConfiguration"
class="org.apache.camel.component.jms.JmsConfiguration">
    <property name="transacted" value="false"/>
  </bean>

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

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

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

  <bean id="jmsTransaction"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
    <property name="transactionTemplate" ref="jmsTransactionTemplate"/>
  </bean>

  <bean id="jmsTransactionTemplate"
class="org.springframework.transaction.support.TransactionTemplate">
    <property name="transactionManager" ref="jmsTransactionManager"/>
    <property name="timeout" value="60"/>
  </bean>





--
View this message in context: http://camel.465427.n5.nabble.com/JMS-Transactions-with-ActiveMQ-tp5717528.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JMS Transactions with ActiveMQ

Posted by Christian Müller <ch...@gmail.com>.
Could you share your route with us to see whether do you use the InOut MEP
or ...?
And could you try the brand new Camel 2.10.2 release together with ActiveMQ
5.7.0?

[1]
http://search.maven.org/#artifactdetails|org.apache.camel|camel-core|2.10.2|bundle

Best,
Christian

On Thu, Aug 16, 2012 at 3:05 PM, maherm <m_...@hotmail.com> wrote:

> Since adding JMS transaction support to our camel / activemq routes I've
> noticed a lot of "transport interrupted" and "transport resumed" log
> messages being outputted from our application. Is this change in behavior
> to
> be expected? Does the JMS connection handling change once a
> TransactionManager has been introduced? Are the ActiveMQ connections or
> sessions dropped and reopened periodically, or after a period of
> inactivity?
>
> The application itself appears to work fine; the JMS messages are still
> processed successfully and when a transaction is rolled back then the
> message isn't lost. However we have a monitoring system monitoring the
> application's log files, in particular for any connection errors between
> the
> application and the activemq broker. This leads to a lot of alarms being
> raised.
>
> Im using Camel Version: 2.10.0, ActiveMQ: 5.5.1 and Spring: 3.1.0
>
> Thanks in advance for any help.
>
> Below is the spring / activemq configuration we're using:
>
>   <bean id="activemqtx"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>     <property name="configuration" ref="txJmsConfiguration"/>
>     <property name="transactionManager" ref="jmsTransactionManager"/>
>   </bean>
>
>
>   <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>     <property name="configuration" ref="ntxJmsConfiguration"/>
>   </bean>
>
>   <bean id="amqPooledConnectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory"
> destroy-method="stop">
>     <property name="maxConnections" value="5"/>
>     <property name="connectionFactory" ref="amqConnectionFactory"/>
>   </bean>
>
>   <bean id="amqConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>     <property name="brokerURL" value="${activemq.brokerURL}"/>
>     <property name="userName" value="${activemq.username}"/>
>     <property name="password" value="${activemq.password}"/>
>     <property name="exceptionListener" ref="jmsExceptionListener"/>
>     <property name="transportListener" ref="jmsTransportListener"/>
>     <property name="redeliveryPolicy" ref="redeliveryPolicy"/>
>   </bean>
>
>   <bean id="jmsExceptionListener" class="..JmsExceptionListener"/>
>
>   <bean id="jmsTransportListener" class=".JmsTransportListener"/>
>
>   <bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
>     <property name="backOffMultiplier" value="2"/>
>     <property name="collisionAvoidancePercent" value="15"/>
>     <property name="initialRedeliveryDelay" value="5000"/>
>     <property name="maximumRedeliveries" value="2"/>
>     <property name="useCollisionAvoidance" value="false"/>
>     <property name="maximumRedeliveryDelay" value="5000"/>
>     <property name="redeliveryDelay" value="5000"/>
>     <property name="useExponentialBackOff" value="false"/>
>   </bean>
>
>   <bean id="abstractJmsConfiguration" abstract="true"
> class="org.apache.camel.component.jms.JmsConfiguration">
>     <property name="connectionFactory" ref="amqPooledConnectionFactory"/>
>     <property name="exceptionListener" ref="jmsExceptionListener"/>
>   </bean>
>
>   <bean id="txJmsConfiguration" parent="abstractJmsConfiguration"
> class="org.apache.camel.component.jms.JmsConfiguration">
>     <property name="transacted" value="true"/>
>     <property name="cacheLevelName" value="CACHE_CONSUMER"/>
>     <property name="transactionTimeout" value="60000"/>
>   </bean>
>
>   <bean id="ntxJmsConfiguration" parent="abstractJmsConfiguration"
> class="org.apache.camel.component.jms.JmsConfiguration">
>     <property name="transacted" value="false"/>
>   </bean>
>
>   <bean id="jmsTransactionManager"
> class="org.springframework.jms.connection.JmsTransactionManager">
>     <property name="connectionFactory" ref="amqPooledConnectionFactory"/>
>   </bean>
>
>   <bean id="PROPAGATION_REQUIRED"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>     <property name="transactionManager" ref="jmsTransactionManager"/>
>   </bean>
>
>   <bean id="PROPAGATION_REQUIRES_NEW"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>     <property name="transactionManager" ref="jmsTransactionManager"/>
>     <property name="propagationBehaviorName"
> value="PROPAGATION_REQUIRES_NEW"/>
>   </bean>
>
>   <bean id="jmsTransaction"
> class="org.apache.camel.spring.spi.SpringTransactionPolicy">
>     <property name="transactionTemplate" ref="jmsTransactionTemplate"/>
>   </bean>
>
>   <bean id="jmsTransactionTemplate"
> class="org.springframework.transaction.support.TransactionTemplate">
>     <property name="transactionManager" ref="jmsTransactionManager"/>
>     <property name="timeout" value="60"/>
>   </bean>
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/JMS-Transactions-with-ActiveMQ-tp5717528.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



--