This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Message redelivery - is it default?

 
Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have studied that when MDB has Tx Required, the redelivery semantics applied.

I threw an exception from an onMessage() method, but always get redelivery happening. I tried to change the Transaction attributes to Required and Not Supported, but that does not seem to make any difference.


The logs contain the proof for redelievery.



Could you help me understand.

Thanks in advance,
Rajesh
 
Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have come near the solution.

The magic of redelivery happened because of context.setRollbackOnly(). When I commented that line, the exception did not cause the message to get redelivered.

There was no change in behavior when the onMessage had Transaction attribute as REQUIRED or NOT_SUPPORTED. I read in one exam simulator that a guaranteed message consumption and persistence of the message in DB requires that the MDB start the consumption with a Transaction required. However, with just context.setRollbackOnly() that could be achieved.

May i have your input on this.

Regards,
Rajesh

 
Rajesh So
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, I did not find any differences or benefits in using either of the Transaction attributes in the onMessage method. Could you please help me when to use either of them and what are the benefits.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!