2 Replies Latest reply on Dec 5, 2003 9:44 AM by rkm1

    MDB Rollback - HELP

    rkm1

      Hello,

      I'm trying to figure out how to rollback (ensure the message gets redelivered) in a MDB.

      I followed Adrians advice (see below) but have had no success.

      I'm watching the data\jbossmq\file\queue and the messages are consumed.


      ****************************************


      For the 256th factorial time!

      MDBs do not acknowledge messages
      (at least not directly).
      It is also an error to leak
      Exceptions from onMessage()

      onMessage is part of the JMS spec.
      If you want to the talk to the MDB use the
      MessageDrivenContext.

      You should configure your onMessage to run inside
      a transaction then code something like:

      MessageDrivenContext ctx;

      public void setMessageDrivenContext(MessageDrivenContext ctx)
      {
      this.ctx = ctx;
      }

      public void onMessage(Message m)
      {
      try
      {
      doSomething(m);
      }
      catch (ExpectedException e)
      {
      handleExpected(e);
      }
      catch (Throwable e)
      {
      log.warn("Error occurred", e);
      ctx.setRollbackOnly();
      }

      This is the only time I'm going to post this -
      this month :-)

      Regards,
      Adrian


      ****************************************


      Am I missing something?

      Please help.