You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Marco Zapletal (JIRA)" <ji...@apache.org> on 2012/06/01 14:08:22 UTC

[jira] [Commented] (CAMEL-5055) Offer a way to not set a transaction manager in camel-jms

    [ https://issues.apache.org/jira/browse/CAMEL-5055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13287351#comment-13287351 ] 

Marco Zapletal commented on CAMEL-5055:
---------------------------------------

Thanks. Since some days, I also notice that approx. 5% of my messages get redelivered

Example log entry: Transaction commit (0x26b5f36e) redelivered(true) for (MessageId: ID:MYSERVER-51520-1338396250920-0:4:2:1:30 on ExchangeId: ID-4711)) [Camel (myserver) thread #8 - JmsConsumer[MyJMSQueue]] [o.a.c.s.s.TransactionErrorHandler]  

Could it be the case that the patch provokes this, since I haven't had these redeliveries before.
                
> Offer a way to not set a transaction manager in camel-jms
> ---------------------------------------------------------
>
>                 Key: CAMEL-5055
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5055
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-activemq, camel-jms
>    Affects Versions: 2.9.0
>            Reporter: Torsten Mielke
>            Assignee: Babak Vahdat
>              Labels: camel-jms, transactions
>             Fix For: 2.10.0
>
>         Attachments: camel-5055acknowledgeMode_SESSION_TRANSACTED_cannot_be_used_for_an_non-transacted_Session.zip
>
>
> The following sample Spring config sets up a camel-activemq component
> {code:xml}
> <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"> 
>      <property name="configuration" ref="jmsConfigAmq" />
>   </bean>
>   
>   <bean id="jmsConfigAmq" class="org.apache.activemq.camel.component.ActiveMQConfiguration" >
>       <property name="connectionFactory" ref="jmsPooledConnectionFactory" /> 
>       <property name="transacted" value="true"/> 
>       <!--  <property name="transactionManager" ref="jmsTransactionManager" />  -->
>       <property name="cacheLevelName" value="CACHE_CONSUMER"/>
>   </bean>
>   
>   <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
>     <property name="connectionFactory" ref="jmsPooledConnectionFactory" />
>   </bean>           
>      
>   <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"> 
>     <property name="brokerURL" value="tcp://localhost:61617" /> 
>     <property name="watchTopicAdvisories" value="false" />
>   </bean>
> 	    
>    <bean id="jmsPooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" >
>       <property name="maxConnections" value="1"/>
>       <property name="connectionFactory" ref="jmsConnectionFactory"/>
>    </bean>
> {code}
> The ActiveMQConfiguration sets transacted=true and configures for a JmsTransactionManager. Also, a PooledConnectionFactory is used. 
> The config for a camel-jms component would be similar.
> The Spring JMS javadoc on [AbstractPollingMessageListenerContainer.setTransactionManager|http://static.springsource.org/spring/docs/3.0.5.RELEASE/api/org/springframework/jms/listener/AbstractPollingMessageListenerContainer.html#setTransactionManager(org.springframework.transaction.PlatformTransactionManager)] states:
> {quote}
> Note: Consider the use of local JMS transactions instead. Simply switch the "sessionTransacted" flag to "true" in order to use a locally transacted JMS Session for the entire receive processing, including any Session operations performed by a SessionAwareMessageListener (e.g. sending a response message).
> {quote}
> It basically advises to only set transacted=true and don't specify a TX manager. The benefit of doing so is that the cacheLevel setting will be honored when using local transactions without a configured TX manager. When a TX manager is configured, no caching happens at DMLC level and its necessary to rely on a pooled connection factory. This is discussed [here|http://forum.springsource.org/showthread.php?123631-JMS-DMLC-not-caching-connection-when-using-TX-despite-cacheLevel-CACHE_CONSUMER&p=403530&posted=1#post403530].
> However right now its not possible to configure the cameljms or camel-activemq component to not use an external TX manager when transacted=true is set.
> Even when setting lazyCreateTransactionManager=false.
> In case of camel-activemq, it still creates a default JmsTransactionManager:
> {code:title=ActiveMQConfiguration.java}
> public PlatformTransactionManager getTransactionManager() {
>   PlatformTransactionManager answer = super.getTransactionManager();
>   if (isTransacted() && answer == null) {
>     // lets auto-default the transaction manager if its not specified
>     answer = createTransactionManager();
>     setTransactionManager(answer);
>     answer = getTransactionManager();
>   }
>   return answer;
> }
> {code}
> In case of camel-jms it throws an exception:
> {code:title=JmsConfiguration.java}
> PlatformTransactionManager tm = getTransactionManager();
> if (tm != null) {
>   container.setTransactionManager(tm);
> } else if (transacted) {
>   throw new IllegalArgumentException("Property transacted is enabled but a transactionManager was not injected!");
> }
> {code}
> We should allow for using transactions in camel-jms and camel-activemq without setting an external TX manager.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira