Uploaded image for project: 'ActiveMQ Apollo (Retired)'
  1. ActiveMQ Apollo (Retired)
  2. APLO-336

Durable subscribers don't receive messages after reconnect

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Do
    • 1.6
    • None
    • apollo-mqtt
    • None

    Description

      I'm using apollo-mqtt-examples on github (see https://github.com/andto/apollo-mqtt-examples) as the mqtt client to publish and subscribe messages. The example set clean session to true by default. The publisher sends 100 messages + 1 END message, the subscriber will keep connected and receiving message from the broker until received an END message.
      In order to receive the messages sent when the subscriber is offline, I changed the clean session option to true to make it a durable subscriber. But the subscriber could not receive messages correctly after reconnect.

      Test steps:
      [Apollo server restart]
      1. run subscribe client

      2. run publish client, output as follows:
      Using tcp://115.28.32.182:61613 to connect to Apollo
      Sending: Message #0
      Sending: Message #1
      ...
      Sending: Message #99
      Sending END frame

      3. subscribe output as follows:
      Waiting to receive messages
      Will wait for END message or Ctrl+C to exit
      Using tcp://115.28.32.182:61613 to connect to Apollo
      Connected.
      Subscription successful. Waiting for messages...
      Received message: Message #0
      Received message: Message #1
      Received message: Message #2
      Received message: Message #3
      Received message: Message #4
      ...
      Received message: Message #97
      Received message: Message #98
      Received message: Message #99
      Received message: END

      4. Now the subscriber is offline, start the publisher again.

      5. After publish finishes, run the subscriber, it cannot receive any message, force close the subscriber.

      6. Run the subscriber, then run the publisher, after 100+1 messages are already published, there are 2/4 online message lost, the subscriber's output is:
      Waiting to receive messages
      Will wait for END message or Ctrl+C to exit
      Using tcp://mq.beepower.com.cn:61613 to connect to Apollo
      Connected.
      Subscription successful. Waiting for messages...
      Received message: Message #2
      Received message: Message #3
      Received message: Message #6
      Received message: Message #7
      Received message: Message #10
      Received message: Message #11
      Received message: Message #14
      Received message: Message #15
      ...
      Received message: Message #90
      Received message: Message #91
      Received message: Message #94
      Received message: Message #95
      Received message: Message #98
      Received message: Message #99

      7. As you can see, only half of the messages can be consumed by the receiver, other messages are put into apollo's message queue. In the apollo web dashboard, there are 152 messages in the queue (100+1 offline messages and 51 online messages).

      I also used paho as the publish and subscribe client, and the problem is almost the same. In paho case, the subscribe client could receive all the offline messages after the first reconnection, but with 1/3 online message lost. The subscriber could not receive all the offline messages after the second reconnection, and with 2/4 online message lost.

      So I think maybe it's the apollo broker's problem. How to solve this problem to make my subscriber to receive messages correctly?

      Attachments

        1. apollo.xml
          3 kB
          Wenxuan Yang
        2. apollo-mqtt-examples-master.zip
          883 kB
          Wenxuan Yang

        Activity

          People

            Unassigned Unassigned
            ywx217 Wenxuan Yang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment