aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Transactions questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Transactions questions" Watch "Transactions questions" New topic
Author

Transactions questions

Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
I have read in the book : EJB 3.0 that "Message Driven Beans" can only have two transaction attributes which are :

1- Not Supported
2- Required

I do not understand why in Message Driven Bean I cannot user other transaction attributes such as RequiresNew or Mandatory.

Thanks in advance.


SCJP, SCJD,SCWCD,SCDJWS,SCEA 5 MCP-C#, MCP-ASP.NET - http://www.khaledinho.com/
Life is the biggest school
Amol Nayak
Ranch Hand

Joined: Oct 26, 2006
Posts: 218

Khaled said:
I do not understand why in Message Driven Bean I cannot user other transaction attributes such as RequiresNew or Mandatory


Mandatory means a transaction is required when the method is invoked.
MDB's have no clients and container invokes the onMessage method, so there is no incoming transaction and hence Mandatory is not permitted.

Requires new means there is an incoming transaction, it is suspended and new transaction is started. Since there is no client there is no incoming client. So RequiredNew makes no sense.
Camilo Morales
Ranch Hand

Joined: Jul 14, 2007
Posts: 92
I find this explanations from O'Reilly's book very clear:


Message-driven beans may declare only the NotSupported or Required transaction attribute. The other transaction attributes don't make sense in message-driven beans because they apply to client-initiated transactions. The Supports, RequiresNew, Mandatory, and Never attributes are all relative to the transaction context of the client. For example, the Mandatory attribute requires the client to have a transaction in progress before calling the enterprise bean. This is meaningless for a message-driven bean, which is decoupled from the client.

The NotSupported transaction attribute indicates that the message will be processed without a transaction. The Required transaction attribute indicates that the message will be processed with a container-initiated transaction.


Regards,


Camilo Morales<br />SCJP 5, SCBCD 5
Khaled Mahmoud
Ranch Hand

Joined: Jul 15, 2006
Posts: 361
When I read this explanation for the first time, I thought that "Client" only means an application client and it did not come to my mind that it could be an EJB well. That's why there was a confusion about this explanation.

When reading Amol explanation i thought that it could be another session that could invoke this statement. Exactly this statement made me figure this out


container invokes the onMessage method,


Thank you both for help.
[ August 23, 2007: Message edited by: Khaled Mahmoud ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transactions questions