It's not a secret anymore!*
The moose likes EJB and other Java EE Technologies and the fly likes Exception handling for message-driven EJBs - best practices? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Exception handling for message-driven EJBs - best practices?" Watch "Exception handling for message-driven EJBs - best practices?" New topic
Author

Exception handling for message-driven EJBs - best practices?

Jimmy Ho
Ranch Hand

Joined: Jul 31, 2007
Posts: 61
So I've got a MDB and I hear that if the MDB throws an exception in the onMessage() method, the JMS provider (WebSphere MQ 5.3) will go ahead and put the message back on the queue (and after a few retries, I think it goes to an error queue).

That's the behavior I want. If the above is true, then what's the best practice for throwing the exception? I can't change the throws clause on the method without getting compiler errors, unless it's a Runtime exception. So should I just throw a runtime exception? Or am I missing something?
Abhinav Srivastava
Ranch Hand

Joined: Nov 19, 2002
Posts: 349

if at all you have to, throw an EJBException from onMessage().
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception handling for message-driven EJBs - best practices?