11 Replies Latest reply: May 26, 2012 10:31 PM by Clebert Suconic RSS

    RuntimeException in MessageHandler doesn't rollback consumer transaction

    Felipe Kamakura Newbie

      Hello everyone,

       

      I'm currently using HornetQ Core API for async messaging. I noticed in my tests something different than what I expected, though:

       

      Suppose a MessageHandler that do the following:

       

       

      class MyHandler implements MessageHandler {
      
          public void onMessage(ClientMessage arg0) {
              System.out.println("Received message from App");
              throw new RuntimeException();
          }
      }
      
      

       

      Shouldn't the RuntimeException rollback the transaction and redeliver the message (in this case infinitely)? It doesn't happen.

       

      Instead, if I explicitly call rollback in the session, it does redeliver:

       

       

          public void onMessage(ClientMessage arg0) {
              System.out.println("Received message from App");
              try {
                  session.rollback();              // Session was injected by constructor
              } catch (HornetQException e) {
                 //
              }
          }
      
      

       

       

      Since we're talking about redeliver, I just wanted to point out that even if I set <max-delivery-attempts>, it will redeliver infinitely. Is is a bug?

       

       

      Oh, I'm using Hornet 2.0.0ga, but I tested with 2.2.5.final and the same happened.

       

      Thanks in advance!