1 Reply Latest reply on Jan 11, 2007 9:43 AM by Tim Fox

    MDB Redelivery bizarre behaviour

    mskonda Apprentice

      I created a simple durable MDB.

      In my onMessage(), I create an Exception and throw it so that during try-catch, I'll rollback the Tx by calling mdbContext.setRollbackOnly().

      I pump in messages to the destination where this MDB is listening to.

      First message is redelivered as expected. The second time, it won't. Thirdtime again it does. Fourth time no.. So, the redelivery occurs for every alternate process..!!

      Either I must be missing fundamentally something or something is wrong with MBD redelivery mechanism.
      My onMessage looks like this:

      public void onMessage(Message message)
       logger.info("---> onMessage" + this.hashCode() + ": message "
       + message.getJMSMessageID());
       logger.info(" ---> MESSAGE IS REDELIVERED ");
       logger.info(" ---> Throwing ex");
       throw new Exception("ex");
       } catch (Exception e)
       .info(" ---> Exception occured. Rolling back Tx (must retry)-"
       + mdbContext);

      My deployment descriptors:

       <configuration-name>Standard Message Driven Bean</configuration-name>

      My console log when a message is first sent:

      14:31:32,723 INFO [TestMDB] ---> onMessage34695986: message ID:JBM-4567040
      14:31:32,723 INFO [TestMDB] ---> Throwing ex
      14:31:32,723 INFO [TestMDB] ---> Exception occured. Rolling back Tx (must retry)
      14:31:32,727 INFO [TestMDB] ---> onMessage34695986: message ID:JBM-4567040
      14:31:32,727 INFO [TestMDB] ---> MESSAGE IS REDELIVERED
      14:31:32,727 INFO [TestMDB] ---> Throwing ex
      14:31:32,727 INFO [TestMDB] ---> Exception occured. Rolling back Tx (must retry)
      14:31:32,730 INFO [TestMDB] ---> onMessage34695986: message ID:JBM-4567040
      14:31:32,730 INFO [TestMDB] ---> MESSAGE IS REDELIVERED
      14:31:32,730 INFO [TestMDB] ---> Throwing ex
      14:31:32,731 INFO [TestMDB] ---> Exception occured. Rolling back Tx (must retry)
      14:31:32,733 INFO [TestMDB] ---> onMessage34695986: message ID:JBM-4567040
      14:31:32,734 INFO [TestMDB] ---> MESSAGE IS REDELIVERED
      14:31:32,734 INFO [TestMDB] ---> Throwing ex
      14:31:32,734 INFO [TestMDB] ---> Exception occured. Rolling back Tx (must retry)
      14:31:32,736 WARN [DLQHandler] Message resent too many times; sending it to DLQ; message id=ID:JBM-4567040

      When a message is sent second time:
      14:31:50,791 INFO [TestMDB] ---> onMessage34695986: message ID:JBM-4567296
      14:31:50,791 INFO [TestMDB] ---> Throwing ex
      14:31:50,791 INFO [TestMDB] ---> Exception occured. Rolling back Tx (must retry)

      I am a bit confused - so any pointers are higly appreciated!