activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: ActiveMQ and JPA with global transactions
Date Mon, 05 Nov 2007 16:43:15 GMT
See the background here...

Typically you either need to implement your own duplicate message
detector, use an idempotent consumer...
or use XA.

Another approach I've used with customers is that for JPA stuff that
might fail, use a JPA endpoint in Camel as part of your JMS send (so
it really just does a JPA insert under the covers using your
JpaTemplate object and using the same transaction), then in the
ActiveMQ broker bridge from your entity to a queue.

e.g. in your code send to destination

new CamelDestination("jpa:com.acme.MyEntity");

then in your activemq.xml have a rule...

  <from "jpa:com.acme.MyEntity"/>
  <to "activemq:MyQueue"/>

This then means rather than having the XA issue; you can stick to
simple JDBC operations and transactions; then get the broker to poll
the database and bridge it to a message queue in a separate
transaction (which typically will have less risk of creating

If you're not using XA you really should have some kinda duplicate
detection in there just in case though.

On 05/11/2007, dmd <> wrote:
> Hi all,
> I am using JPA (currently with OpenJPA) to persist the execution state of a
> process.  I sometimes need to use the same transaction to consume a message,
> update the state of the process and persist it to disk, and generate some
> message.
> Essentially I have two services which communicate via JMS and both need to
> recover from failures and not lose their state or messages in transit.
> Now, I can't yet figure out how to configure the system in order to share
> the transactional context...  Furthermore, I don't know if that requires
> that both the ActiveMQ broker and the JPA must use the same DB.  (Obviously
> there is a requirement that the DB itself be highly available.  We are using
> MS SQL Server with a shared storage configuration.)
> Any help would be appreciated, including someone telling me that I'm on
> totally the wrong track and I should use some other technologies.
> Cheers,
> Dan
> --
> View this message in context:
> Sent from the ActiveMQ - User mailing list archive at


Open Source SOA

View raw message