• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JMS - Effect on Message queue on exception in message consumer.

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose a process puts a message in queue and say a mdb receives it and sends a mail to say client.
Now if during mdb is sending message, any exception occurs, message is not sent. Then what will happen to the message. What will be the queue state, Will the unsent message be sent back to the queue, If not how can that be achieved.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you throw an exception from inside onMessage(), the container will know that it has to put the message back into the Queue.
 
Chetan M
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sergiu truta:
If you throw an exception from inside onMessage(), the container will know that it has to put the message back into the Queue.


which exception should be thrown. throwing JMSException will do??
of any other exception has to be thrown.
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Throw a system exception or rollback the transaction. For example:
inside your MDB you have:
private MessageDrivenContext ctx;
public void onMessage(Message msg){
....
//if you want to put the message back into the queue
ctx.setRollbackOnly();

Try these options.
 
What are you doing? You are supposed to be reading this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic