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 BMT and Bean Type. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "BMT and Bean Type." Watch "BMT and Bean Type." New topic
Author

BMT and Bean Type.

Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
On Page 342 Core EJB Specs:

If the client request is associated with a transaction T1, and the instance is not associated with a transaction, the container suspends the client�s transaction association and invokes the method with an unspecified transaction context. The container resumes the client�s transaction association (T1) when the method (together with any associated interceptor methods) completes. This case can never happen for a message-driven bean or for the invocation of a web service endpoint method of a stateless session bean.

Doubt:

Message driven beans can have Transaction attribute specified as Not Supported or Required. In the case of Not Supported - the above can happen?.
Also, why is not applicable for invocation of a web service endpoint method of a stateless session bean and applicable for a stateless session bean call?

Please guide,
Shivani


/** Code speaks louder than words */
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Yes, MDB and Web Service End point session bean this cannot be happen for both of them.

In case of MDB, the message arrives at container and it invokes the onMessage method, so there is no caller and hence there is not a transaction.

In case of WebService Endpoint, currently there is no way to propogate the caller's initiated transaction to your EJB. Caller can be .NET client or in anyother language, so there is no mechanism to propogate that caller's initiated transaction to WebService End point.
Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
Thanks Ali.

Please confirm the following:

If Client is associated with Transaction - T1 and invokes the MDB having transaction attribute Not Supported. Then :

1. The Client's transaction T1 would not be suspended.
2. MDB would be invoked with unspecified transaction context.
3. Execution would be continued on client's method.

Regards,
Shivani
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
If Client is associated with Transaction - T1 and invokes the MDB having transaction attribute Not Supported.


Client cannot call the MDB directly because client will simply generate the message for some specific Queue or Topic in the container and it is not required that MDB should be up at that time, MDB can be down. If destination is Queue or Durable Topic then after the MDB will be up, it will get the message.

So container calls the onMessage method of MDB, so there is no client associated with it and hence no transaction context. That is why MDB supports only two transaction attributes NotSupported or Required. If MDB's attribute is NotSupported then it will run in un specified transaction context and if transaction attribute is Required then a new transaction will be started by container.

Hope it clarifies.
Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
Ali,
Thanks!~ That clarifies it
warren li
Ranch Hand

Joined: May 23, 2006
Posts: 128
I think the spec is correct also because MDB is asynchronous. The calling method won't suspend to wait for MDB to complete. The calling method will continue executing after it sends the message to the JMS destination. So, the suspension of the calling tx does not apply to MDB.


SCBCD 1.3: 94%<br />SCWCD 1.4: 91%<br />SCJP 5: 95%
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BMT and Bean Type.
 
Similar Threads
SessionSynchronization for stateful CMT beans - reloaded
MDB and Bean-managed tx question
BMT not propogated to invoked beans
dbt in exceptions + transactions + Session bean (BMT)
Stateless session beans and Transactions