It's not a secret anymore!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Why not use RequiresNew/Supports 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 "Why not use RequiresNew/Supports for MDB?" Watch "Why not use RequiresNew/Supports for MDB?" New topic
Author

Why not use RequiresNew/Supports for MDB?

Justin
Greenhorn

Joined: Sep 10, 2004
Posts: 6
One of the things mentioned in HFE is that MessageDrivenBeans should use only Required or NotSupported as Tx attributes.

But since the container calls the MDB's onMessage method, we can assume that the onMessage call is called without any tx context.

It will be like this when Required is used

                           onMessage
                            (Tx A)
Container    --->    Container
(no tx)                        (No tx)


Wont it be the same when when the RequiresNew is used too?

Also we assume that when the container calls NotSupports, it is calling without any tx context. If that is the case, why cant Supports be a valid attribute (because Supports and NotSupported will look the same)?

So why cant we use it them?
[ November 21, 2004: Message edited by: Justin ]
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3199
    
    5
Howdy,

The reason is because client can not pass his transaction to MDB and he can not receive back MDB's exception.

Here what EJB 2.0 specification says:


Only the NotSupported and Required transaction attributes may be used for message-driven beans.

The use of the other transaction attributes is not meaningful for message-driven beans because there can be no pre-existing transaction context (RequiresNew, Supports) and no client to handle
exceptions (Mandatory, Never).


regards,
MZ


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why not use RequiresNew/Supports for MDB?
 
Similar Threads
MDB and transaction attributes
Understand MDB Transaction
EJB Transaction
HF EJB "Sharpen your pencil p. 497"
Transaction attributes and MDB methods