Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception handling for message-driven EJBs - best practices?

 
Jimmy Ho
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if at all you have to, throw an EJBException from onMessage().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic