1 Reply Latest reply on Jun 2, 2005 8:12 PM by genman

    MDB + setRollbackOnly question

    optimusprime

      Hello there! I have an MDB which peforms some database related logic on its onMessage() method. If something bad happens, I'd like to rollback the transaction so nothing is persisted (I'm using hibernate). But when I do this:
      catch(Exception ex){
      ctx.setRollbackOnly();
      }

      It seems that the message receive is not acknowledge, and then the container ends up in an infinite loop trying to consume the message every time. What I'd like to happen is, on error, the message should be purged from the queue?

      Any ideas?

      Best regards

      Vinicius

      PS: Didn't put all the code and descriptors here, to let the msg clean. If required to help please let me know.

        • 1. Re: MDB + setRollbackOnly question
          genman


          Typically, you want the commit of the message and DB to happen at the same time. You can do a rollback, and the second time around, ignore the message. You can do this by keeping a hash table by message ID in your MDB of messages to subsequently ignore.