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!
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.
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)
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop