File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Transaction in MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Transaction in MDB" Watch "Transaction in MDB" New topic
Author

Transaction in MDB

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
On p.176 of EBJ 3 in Action (2nd edition),

MDS don't support all six transaction attributes. MDBs support only REQUIRE or NOT_SUPPORT.... There is no existing transaction to suspend or join when a message is delivered, therefore, REQUIRE_NEW, SUPPORTS, and MANDATORY make no sense... The two options you have available are REQUIRE if you want a transaction.....


I don't understand this point:
there is no existing transaction when a message is delivered from a queue to an MDB. Why we still need a transaction as it says " REQUIRE if you want a transaction" ?
When a message is delivered from the queue to the MDB, is this a transaction?
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 775
Let me answer my own question. On p.113 of EJB in Action,

By default, the container will start a transaction before the onMessage method is invoked and will commit the transaction when the method returns..... The container assumes that a transaction is required by the MDB...


So, does that mean the implementations inside the onMessage method can be a transaction?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10213
    
166

Himai Minh wrote:

I don't understand this point:
there is no existing transaction when a message is delivered from a queue to an MDB. Why we still need a transaction as it says " REQUIRE if you want a transaction" ?
When a message is delivered from the queue to the MDB, is this a transaction?


You mark the onMessage() method with REQUIRE (which by the way is the default), if you want the container to start a transaction for you while you are processing the delivered message in your onMessage() method.

[My Blog] [JavaRanch Journal]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transaction in MDB