Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic