See the background here...
http://activemq.apache.org/should-i-use-xa.html
Typically you either need to implement your own duplicate message
detector, use an idempotent consumer... 幂等消费者. 核心关键
http://activemq.apache.org/camel/idempotent-consumer.html
or use XA.
Another approach 方法 I've used with customers is that for JPA stuff that
might fail (因为jpa可能失败), 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...
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
duplicates).
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
>
> 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: http://www.nabble.com/ActiveMQ-and-JPA-with-global-transactions-tf4752732s2354.html#a13590338
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>
|