9 Replies Latest reply on Oct 25, 2002 10:47 PM by adrian.brock

    Message acknowledgement and durable subscription

    bernd.koecke

      Hi,

      I'm using JBoss 3.2 on Linux, Sun JDK 1.3.1_03. I have a problem with a durable topic subscriber. I would like to use the Session.CLIENT_ACKNOWLEDGE mode for the subscriber. So when the subscriber dies while he processes the message he will get this message again after a restart.

      In my testcase I set the acknowledge mode of the durable topic subscriber session to Session.CLIENT_ACKNOWLEDGE and never acknowledge any message. Then I shutdown the receiving client. After resubscribing the receiver I expected that it gets all the messages again. But it doesn't happen. It only works when I call 'recover' on the session without a shutdown of the receiver. But than it isn't a protection against an Exception, shutdown, etc.

      When I use a transacted session it works with the 'commit' method of the session. But I need the session in the message listener to invoke 'commit' or 'rollback'.

      The jms-apidocs say only that the receiver _may_ get the message again and not _must_.

      Do I have to use a transacted session or is it a bug in the implementation? If its a bug I could look into the code and try to find the position.

      Thanks

      Bernd

        • 1. Re: Message acknowledgement and durable subscription

          Hi,

          I committed a "fix" to 3.2 yesterday that should
          solve your problem.
          The spec isn't very clear. The closest I could come
          to an answer was the javadoc for QueueSession

          My fix, nacks (negative acknowledgement) all
          unacknowledged messages at session close
          or when the connection to the client drops.

          NOTE: There is still an outstanding bug, where
          if you shutdown jboss it loses the "redelivered"
          flag. It's not top of my list of things to fix at
          the moment, so maybe you can look at this? :-)

          Regards,
          Adrian

          • 2. Re: Message acknowledgement and durable subscription
            bernd.koecke

            > Hi,
            >
            > I committed a "fix" to 3.2 yesterday that should
            > solve your problem.
            > The spec isn't very clear. The closest I could come
            > to an answer was the javadoc for QueueSession
            >
            > My fix, nacks (negative acknowledgement) all
            > unacknowledged messages at session close
            > or when the connection to the client drops.

            Thanks a lot! That solved my problem.

            >
            > NOTE: There is still an outstanding bug, where
            > if you shutdown jboss it loses the "redelivered"
            > flag. It's not top of my list of things to fix at
            > the moment, so maybe you can look at this? :-)

            Sure, I can give it try, but I don't have a deep knowledge of the sources, so it will take some time.

            Thanks again

            Bernd

            • 3. Re: Message acknowledgement and durable subscription
              bernd.koecke

              Hi,

              I tested a little bit more and it seems there is a little bug. I can't change the message selector of a durable subscription. In my test I make a durable subscription with clientId=TestClient and message selector EventName='test1'. All works fine, I send messages with the right property and the subscriber gets them. But when I shutdown the client and reconnect again with the same clientId but a selector like EventName='test2', the subscriber gets no messages at all (I send new messages with the property set to 'test2'). The jbossmq-state.xml isn't updated too. When I reconnect with the selector for test1 all works fine again. I could only change the selector when I unsubscribe from the topic.

              A few days ago it was possible to reconnect with the same clientId and a different selector.

              The state of acknowledgeMode or deliveryMode doesn't change the behaviour.

              Thanks

              Bernd

              • 4. Re: Message acknowledgement and durable subscription

                Hi,

                I don't think my fix has broken this. :-)
                It looks like an existing bug.

                The following comment appears in AbstractStateManager

                // The topic previously subscribed to is not the same as the
                // one in the subscription request.
                // TODO: we do currently no check if the selector has changed.
                else if (!subscription.getTopic().equals(topic.getName()))
                {

                I would guess it should have an extra check something
                like:

                else if (!subscription.getTopic().equals(topic.getName())
                || !subscription.getSelector().equals(sub.getSelector()))

                If you have a testcase and the source do you want to
                try this fix?

                Regards,
                Adrian

                • 5. Re: Message acknowledgement and durable subscription

                  It's more complicated than that,
                  so don't waste your time :-)

                  I think I've got a working, just writing some tests...

                  Regards,
                  Adrian

                  • 6. Re: Message acknowledgement and durable subscription
                    bernd.koecke

                    Testcases are no problem, should I test your last fix? I have a cvs version from yesterday and could update/patch to whatever you want :).

                    Bernd

                    • 7. Re: Message acknowledgement and durable subscription

                      Sorry for the delay, I've been firefighting some
                      other problems. :-(

                      I've committed the fix for selector changes into 3.2

                      Regards,
                      Adrian

                      • 8. Re: Message acknowledgement and durable subscription
                        bernd.koecke

                        Thank you very mutch! It works very well.

                        Is the bug you mentioned above still valid? I didn't find it in Bugzilla.

                        Bernd

                        • 9. Re: Message acknowledgement and durable subscription

                          The redelivered flag after a server restart?
                          It is still a bug.

                          Bugzilla?
                          Try www.sf.net/projects/jboss and click on bugs if
                          you want to report it.

                          Regards,
                          Adrian