How to Configure MDB Message Redelivery When onMessage() Returns a Failure?

(Doc ID 1054218.1)

Last updated on NOVEMBER 05, 2016

Applies to:

Oracle Containers for J2EE - Version: and later   [Release: AS10gR3 and later ]
Information in this document applies to any platform.


Having a CMT message-driven bean, a J2EE application is deployed into 10.1.3 OC4J.
If an error is detected in the onMessage(), the application rolls backs the transaction (by calling   setRollbackOnly() method , or throws an ApplicationException message) :


public class TestMessageDrivenEJBBean implements MessageListener,MessageDrivenBean {
private MessageDrivenContext context;

public void setMessageDrivenContext(MessageDrivenContext icontext) throws EJBException {
context = icontext;

public void ejbCreate() { }


public void onMessage(Message message) {
// ... normal message handling code
if (error ) {
// ... error handling code

public void ejbRemove() {

In this case (transaction is rollback), after the onMessage() treatment, the message will be left in the JMS destination. And, OC4J will try automatically to re-deliver the message by re-calling the onMessage() method again.

This note demos how a message-driven bean can be configured to make OC4J re-attempt to deliver the message x number of times.


Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms