2 Replies Latest reply on Aug 29, 2003 7:25 AM by Adrian Brock

    NonXA Rollback consumes message

    gavinandrews Newbie

      With FioranoMQ 5.21 (nonXA) and JBoss 3.2.1

      I have a simple "Required" MDB which throws a EJBException (and hence should be rolled back by the container)...

      The message is consumed.

      Why? Shouldn't the message remain on the queue?

      [I looked at the JBoss source and it looks like for a non-XA JMS Provider the message will always be consumed since the onMessage invoked by Fiorano never gets an exception since these are caught and discarded by JBoss]?

        • 1. Re: NonXA Rollback consumes message
          gavinandrews Newbie

          Well I read Chapter 15 of the EJB 2.0 spec and found "clients should not throw RuntimeException" in onMessage....

          and I read Section 4.5.2 in the JMS Spec and it said "RuntimeException is considered a client programming error"...

          so I guess I need a new approach...

          Is there a good way to determine that the Transaction will be rolled back and forward the message to the DLQ before returning (without exception) from the MDB onMessage?

          A Snippet would be appreciated if someone else is already doing this.

          Thanks,
          Gavin

          • 2. Re: NonXA Rollback consumes message
            Adrian Brock Master

            MessageDrivenContext ctx;

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

            public void onMessage(Message message)
            {
            try
            {
            handleMessage(message);
            }
            catch (Throwable t)
            {
            ctx.setRollbackOnly();
            reportError(t);
            }

            Regards,
            Adrian