1- Not Supported
I do not understand why in Message Driven Bean I cannot user other transaction attributes such as RequiresNew or Mandatory.
Thanks in advance.
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.
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.
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 ]