camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Bug?
Date Fri, 08 Feb 2008 11:16:03 GMT
On 08/02/2008, Magnus Heino <magnus@filur.org> wrote:
> Hi.
>
> I have XA transactions working now... but only using "pure" spring, not
> camel.
>
> My code looks like this now:
>
> @Component("updateService")
> public class UpdateServiceImpl implements UpdateService {
>
>     @EndpointInject(uri = "jms:queue:foobar")
>     private ProducerTemplate producer;
>
>     private final Logger logger = LoggerFactory.getLogger(this.getClass());
>
>     /*
>      * (non-Javadoc)
>      *
>      * @see
> se.lantmateriet.origo.service.internal.UpdateService#handleMessage(
> java.lang.String)
>      */
>     @Transactional(propagation = Propagation.REQUIRES_NEW)
>     public void handleMessage(final String message) {
>         this.logger.info("Message received: '{}'", message);
>     }
>
>     /*
>      * This is triggered by a timer...
>      */
>     public void send() {
>         this.logger.debug("Sending Jms message");
>         this.producer.sendBody("demo");
>     }
> }
>
>
>
> this:
>
>     <camel:camelContext />
>
>     <bean id="updateServiceListenerContainer" class="
> org.springframework.jms.listener.DefaultMessageListenerContainer">
>         <property name="concurrentConsumers" value="1" />
>         <property name="connectionFactory" ref="jmsConnectionFactory" />
>         <property name="transactionManager" ref="transactionManager" />
>         <property name="sessionTransacted" value="true" />
>         <property name="destinationName" value="foobar" />
>         <property name="messageListener">
>             <bean class="
> org.springframework.jms.listener.adapter.MessageListenerAdapter">
>                 <constructor-arg ref="updateService" />
>             </bean>
>         </property>
>     </bean>
>
> Makes my bean consume messages in a xa transaction. Pending message count in
> EMS is 0 when the queue is empty and the app is running, and it stays that
> way when I shutdown jboss.
>
> This config, which really does exactly the same thing afaik, fails:
>
> <bean class="org.apache.camel.component.jms.JmsComponent">
>         <property name="concurrentConsumers" value="1" />
>         <property name="connectionFactory" ref="jmsConnectionFactory" />
>         <property name="transactionManager" ref="transactionManager" />
>         <property name="transacted" value="true" />
>     </bean>
>
>     <camel:camelContext>
>         <camel:route>
>             <camel:from uri="jms:queue:foobar" />
>             <camel:to uri="bean:updateService" />
>         </camel:route>
>     </camel:camelContext>
>
> Pending message count in EMS is 0 when the queue is empty and the app is
> running, but when I shutdown jboss all messages that have been consumed are
> back in ems, pending message size >0.
>
> From my non-expert view, it looks as if mssages are left unacknowledged in
> EMS queue after camel has committed the transaction...?

Thanks for your test case, this is great. I confess to being a little
stumped, as under the covers the Camel component is pretty much doing
exactly the same thing as you are doing via pure Spring - using the
DefaultMessageListenerContainer to do all the heavy lifting.

Its also kinda bizarre that things work for you fine using Camel with
the JMS transaction manager - but as soon as you switch to using XA it
doesn't work.

Are you totally positive you are using exactly the same transaction
manager and JMS connection factory in both cases?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Mime
View raw message