You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Robert Dare <ro...@gmail.com> on 2014/07/22 23:19:19 UTC

Transactions on POJO ProducerTemplates

Hi,

I am producing events through a centralized Spring managed bean that uses
the @EndpointInject annotation.

@EndpointInject(uri="direct:*incomingEvents*")

These events are then routed to individual queues based on a header value:

<route xmlns="http://camel.apache.org/schema/spring" id="mainRoute"
autoStartup="false">
  <from uri="direct:*incomingEvents*"/>
  <choice>
    <when>
      <simple>${header.eventType} == 'MyEvent'</simple>
      <to
uri="spring-amqp:MY_EVENT?type=direct&amp;autodelete=false&amp;durable=true"/>
    </when>
  </choice>
</route>

I want to attach the event producing with the underlying JTA.  I don't want
events going out until the underlying transaction is committed.

This worked great with ActiveMQ, but now I am using RabbitMQ with the
spring-amqp component, and it does not seem so straight forward.

If the PlatformTransactionManager can not speak directly with RabbitMQ, can
I apply the transactions at the Producer endpoint?

Is it possible for the ProducerTemplate to buffer the events until the
transaction is committed and have them all applied in one shot?

Kind regards,

Robert