users@glassfish.java.net

JMS, Entities and JTA

From: Q Beukes <java.net_at_add.za.net>
Date: Thu, 7 Aug 2008 09:04:28 +0200

Hey,

I'm using Toplink JTA with Glassfish v2.

At some point in one of my session beans I update an entity, and then post a
message to a JMS queue, which is on the other end of the queue handled by a
Message Driven Bean.

The problem is that if this message is handled before the transaction
commits, some of the data the MDB is going to use will be outdated. The MDB
needs to use data as set in the EJB right before the message was posted.

Is this the case with JTA?

Also note that the message is posted by a second call to another EJB. It all
works something like this (when I refer to Bean X, I mean Stateless Session
Bean X):
Bean A updates entity B
Bean A calls Bean B to "merge" entity B to persistence context.
Bean A calls Bean C to post a message to JMS topic
MDB handles JMS topic and uses it's supplied information to read from the
database entity B.

In this case, as soon as MDB gets the message, I want to be sure that the
transaction in steps 1/2 has been committed.

-- 
Quintin Beukes