4 Replies Latest reply on Mar 31, 2011 10:51 AM by Angelo Rosenfelder

    Topic-Messages not redelivered after rollback and reconnect.

    Angelo Rosenfelder Newbie

      I'm using apache-activemq-5.4.2-fuse-01-00

      There is a durable subscription on a topic with some messages waiting to be consumed.

       

      The following steps reproduce my problem:

      1. Open a transacted, durable subscriber

      2. consume messages

      3. rollback

      4. closse the session

      5. reconnect

      6. consume messages

       

      I expect to receive the same messages in step 2 and 6, but I never get any message a soon as I close the session (i.e. in step 6).

      Is this the supposed behaviour of a JMS Provider to implicitly acknowledge all messages when a session is closed, even if I call rollback?

       

       

      Following the relevant code-snippet, where in the second receive, I don't receive the rolled-back messages:

       

                  TopicConnection conn = factory.createTopicConnection();

                  conn.setClientID(clientId);

                  TopicSession session = conn.createTopicSession(true, Session.SESSION_TRANSACTED);

                  TopicSubscriber subscriber = session.createDurableSubscriber(myTestTopic, subscriptionName);

                  conn.start();

       

                  Message message = subscriber.receive();

                  while (null != message) {

                      System.out.println("Message received: " + ((TextMessage)message).getText());

                      message = subscriber.receive();

                  }

                  session.rollback();

       

                  subscriber.close();

                  session.close();

                  conn.close();

       

                  conn = factory.createTopicConnection();

                  conn.setClientID(clientId);

                  session = conn.createTopicSession(true, Session.SESSION_TRANSACTED);

                  subscriber = session.createDurableSubscriber(myTestTopic, subscriptionName);

                  conn.start();

       

                  message = subscriber.receive();

                  while (null != message) {

                      System.out.println("Message received: " + ((TextMessage)message).getText());

                      message = subscriber.receive();

                  }