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 Certification (SCBCD/OCPJBCD) and the fly likes Tx attribute for MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Tx attribute for MDB" Watch "Tx attribute for MDB" New topic
Author

Tx attribute for MDB

Li Xin
Ranch Hand

Joined: Feb 06, 2004
Posts: 37
It is known that onMessage in MDB can only be specified as Required or NotSupported, but what about any other method that onMessage invokes? Can we specify other Tx attribute?
Thanks.
Janne Karhu
Ranch Hand

Joined: Oct 29, 2003
Posts: 33
Remember that no other business methods except onMessage(...) can be defined for message driven beans. MDBs do not have home or component interfaces and thus the container is the only "client" calling the method.
You can define additional (public/private what ever) methods to you message driven bean, but they are not known to the container and thus cannot have any tx attributes. Hope this helps!
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

I think he's asking if the MDB calls methods on other beans, can the other beans use Tx attributes other than Required or NotSupported... I would think the answer to this would be yes.

In this case the MDB is just becoming a client of the other bean, so it doesn't impact the other beans in any way, it would behave just like a regular client call in regards to transactions.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Originally posted by Li Xin:
It is known that onMessage in MDB can only be specified as Required or NotSupported, but what about any other method that onMessage invokes? Can we specify other Tx attribute?
Thanks.

For a CMT MDB, there is only one call back method, onMessage().
There could be other private/helper methods defined by the bean developer in the MDB but they inherit the transaction attribute specified from the onMessage() method and are called from the onMessage() method.
For a CMT-MDB there are only 2 cases possible:
Either you have a transaction or you do not have a transaction,
hence only Required and NotSupported are applicable.
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
Agreed. The spec is very clear on CMT MDB options. Section 15.4.7, pages 316-317.
If the bean is specified as using container-managed transaction demarcation, either the Required or the NotSupported transaction attribute must be used. ... stuff about BMT ... If the message receipt is to be part of the transaction, container-managed transaction demarcation with the Required transaction attribute must be used. ... stuff about unspecified transaction context ... There is never a client transaction context available when a message-driven bean is invoked because a transaction context does not flow with a JMS message.

That makes it pretty clear. If the CMT MDB can't get a transaction based on the transaction demarcation of the client, then the only possibilities are to get one from the container (Required) or not to have one at all (NotSupported).


Reid - SCJP2 (April 2002)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tx attribute for MDB
 
Similar Threads
MDB Message Redelivery and discard
MDB's & transaction attributes
Ejb and JMS transactions as one automic transaction
MDB and Tx
Enthuware question doubt