users@glassfish.java.net

Re: Delivery of JMS message in case of distributed transaction

From: <glassfish_at_javadesktop.org>
Date: Tue, 23 Jun 2009 01:36:59 PDT

Hi there, I am experiencing the same issue. I'm Using JPA [hibernate], Glassfish, Spring and i have an MDB.

1] I create a persistent object @Entity, call create [and call entitymanager.flush() even...]
2] I then retrieve the DB generated primary key and put it in the message and put it on the Queue.
3] The async MDB fires and receives the message
4] The ID is retrieved from the message and uses hibernate to load the object by id.
5] Once i have the object i do some updates on it and call merge.

All seems ok until i exit onMessage(). 100% of the time i get an optimisitc lock exception on the object, the first time the message is processed. The message is redelivered after an interval and its process correctly without error the 2nd time. I can confirm that i have put @version on an Integer, not a date that loses precision etc...

Any suggestions would be apreciated. This is proving very difficult to resolve.
[Message sent by forum member 'gregjh' (gregjh)]

http://forums.java.net/jive/thread.jspa?messageID=352466