File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes JMS - Effect on Message queue on exception in message consumer. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS - Effect on Message queue on exception in message consumer." Watch "JMS - Effect on Message queue on exception in message consumer." New topic
Author

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

Chetan M
Ranch Hand

Joined: Dec 18, 2002
Posts: 43
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.


No matter how much you know today, you will have to know more tomorrow.<br /> Hakunamatata !!!
Sergiu Truta
Ranch Hand

Joined: Dec 16, 2003
Posts: 121
If you throw an exception from inside onMessage(), the container will know that it has to put the message back into the Queue.


...watch me...as I'm walking the path...
Chetan M
Ranch Hand

Joined: Dec 18, 2002
Posts: 43
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

Joined: Dec 16, 2003
Posts: 121
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMS - Effect on Message queue on exception in message consumer.
 
Similar Threads
Mdb and runtime exceptions
Message Driven Beans
consuming messages from JMS Queue without other group having to do anything
mock exam + MDB transaction
Authentication JMS/MDB