• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Doubt about MDB behavior

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
k space
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic