A single TX for message consumption and CRUD operation

consider the following scenario?

message producer inserts message into a queue (MQ queue, or a TIBCO JMS Server), MDB running on WebSphere application server consumes the message, parses it and calls a stateless session EJB , which in turn inserts it into the DB.

Can the message consumption (by MDB) and DB insert (by session bean) be part of the same transaction? Meaning, if the DB insert fails, the rollback would result in the message remaining in the queue, so another MDB instance would pick it up.

[525 byte] By [kmkiania] at [2007-11-26 14:27:50]
# 1

Yes, in fact that is the spec-required behavior for JMS MDBs with container-managed

transactions and tx attribute REQUIRED.Of course, the stateless session bean would also

have to have container-managed transactions and a tx attribute that will result in the MDB's

transaction being used (e.g. REQUIRED, SUPPORTS, etc.)

In that case, the message delivery itself is considered to be a unit of work within the global

transaction. If the transaction does not commit, the message will be redelivered.

--ken

ksaksa at 2007-7-8 2:21:30 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...