-
1. Re: entitymanager does not flush ?
jsb Feb 3, 2006 2:09 AM (in response to elkner)I'm seeing the same behavior with RC3. I may be way off on this, but my understanding of flush is that it pushes in-memory changes to the database but does not commit the transaction; so, in a transaction aware database, the updated data is not available to other transactions until the actual commit happens. Again, I could be way off on this. Word from someone who knows would be greatly appreciated.
What bothers me, though, is that the JMS message is being delivered before the transaction has completed. This is definitely happening in my case, using RC3, where an SLSB is used to persist an entity and during the save method a message is sent to an MDB queue to request additional, asynchronous work based on the data of the new entity. Because the message is being delivered before the transaction completes occasionally the new entity is available to the MDB.
According to my understanding of the spec, a JMS message should not be delivered to its final destination until after the transaction from which it originated commits. I'm inferring this from section 12.3.5 where it says: "Because a JMS message is typically not delivered to its final destination until the transaction commits, the receipt of the reply within the same transaction will not take place."
I haven't been able to try the same out with RC5, but I hope to be able to next week. -
2. Re: entitymanager does not flush ?
bill.burke Feb 3, 2006 9:58 AM (in response to elkner)flush() just calls JDBC updates, it doesn't commit.
For transacted JMS use the "java:/JmsXA" factory. It will send all messages at commit time. -
3. Re: entitymanager does not flush ?
jsb Feb 3, 2006 12:16 PM (in response to elkner)Thanks Bill!!
Indeed, replacing@Resource (mappedName="ConnectionFactory") private QueueConnectionFactory factory;
...with...@Resource (mappedName="java:/JmsXA") private QueueConnectionFactory factory;
...in my SLSB has gotten me the behavior I was looking for (messages get picked up by the MDB after the transaction has completed).
Thanks for putting up with my ignorance and sharing your knowledge,
Jonn -
4. Re: entitymanager does not flush ?
elkner Feb 4, 2006 2:29 AM (in response to elkner)"bill.burke@jboss.com" wrote:
flush() just calls JDBC updates, it doesn't commit.
Ahh, so I interpreted the spec not as assumed. OK, thinking a little bit more about it, it is probably not so easy to rollback already db commited data ;-)For transacted JMS use the "java:/JmsXA" factory. It will send all messages at commit time.
That's a very good hint and seems to work :). Already thought about, whether I need to make all TAs bean managed, to accomplish that :(.
Thanx a lot,
jens.