aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubt about MDB behavior 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 "Doubt about MDB behavior" Watch "Doubt about MDB behavior" New topic
Author

Doubt about MDB behavior

Deep Chand
Ranch Hand

Joined: Dec 17, 2002
Posts: 133
Below is my understanding @ MDB (message driven bean). Please correct me if I'm wrong.

With CMT, the acknowledgement is always sent back to the JMS when the method ends successfully i.e. transaction is committed. As the onMessage() can not throw a checked (application) exception, it can only throw a system exception, which implies that if an exception is thrown from an onMessage() method, the transaction will roll back and no acknowledgement is sent back.

With BMT, the acknowledgement is always sent back when the bean provider commits/rollback the transaction explicitly. However, the acknowledgement is ALWAYS sent irrespective of whether the tx is COMMITTED or ROLLED BACK.

Now one doubt:
What will happen if the BMT MDB throws a system exception from onMessage() method?

Please reply.

Thanks
Deep
k space
Ranch Hand

Joined: Jun 25, 2002
Posts: 104
What will happen if the BMT MDB throws a system exception from onMessage() method?


I guess nothing will happen excitingly other than your MDB gets killed.

As you mentioned "With BMT, the acknowledgement is always sent", this is because the default acknowedge-mode for BMT MDB is AUTO_ACKNOWLEDGE. Actually, it does not support other modes like CLIENT_ACKNOWLEDGE. So once the message has been delievered successfully, the acknowledgement is sent regardless of the transaction will be committed/rolled back and your MDB is still alive or dead.


SCEA | SCBCD | SCWCD | SCJP - The kSpace
k space
Ranch Hand

Joined: Jun 25, 2002
Posts: 104
What will happen if the BMT MDB throws a system exception from onMessage() method?


I guess nothing will happen excitingly other than your MDB gets killed.

As you mentioned "With BMT, the acknowledgement is always sent", this is because the default acknowedge-mode for BMT MDB is AUTO_ACKNOWLEDGE. Actually, it does not support other modes like CLIENT_ACKNOWLEDGE. So once the message has been delievered successfully, the acknowledgement is sent regardless of the transaction will be committed/rolled back and your MDB is still alive or dead.
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi Deep

There are two parts to the answer to this question.

1) If a BMT MDB throws a RuntimeException then container log the message, mark the tx for rollback and discard the instance.

2) As far as message acknowledgement is concerned:

If a BMT MDB throws a RuntimeException, the container should not acknowledge the message. From the client perspective, the message consumer continues to exist. If the client continues sending messages to the destination or endpoint associated with the bean, the container can delegate the client´┐Żs messages to another instance.

Thanks

-- Ravi


SCJP, SCJD, SCWCD, SCBCD, SCEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt about MDB behavior