This discussion is archived
4 Replies Latest reply: Sep 30, 2011 2:16 AM by nigeldeakin RSS

some durable subscribers don't receive any messages from broker

886634 Newbie
Currently Being Moderated
Hi,

I have a publish/subscribe scenario set up so that there is one publisher writing to a topic and multiple durable subscribers reading from the same topic. My first step is running the publisher application to publish multiple messages to the topic. Why is that when I start up the subscribers after(they each have their own unique ClientID and name) that not all of the subscribers receive the messages? Either some subscribers receive everything or some receive nothing. Isn't the broker supposed to retain all the messages for all of the durable subscribers?

I am currently using the default values set for the messages. Meaning, they're all set to persistent delivery, priority level 4, and have a lifetime of 0, which is an unlimited message lifetime.

Thanks
  • 1. Re: some durable subscribers don't receive any messages from broker
    jtahlborn Expert
    Currently Being Moderated
    are the durable subscribers subscribed before the publisher publishes the messages?
  • 2. Re: some durable subscribers don't receive any messages from broker
    886634 Newbie
    Currently Being Moderated
    Thanks, I misinterpreted what it meant for a client to be "inactive". So just to be clear, is it completely coincidental that some subscribers are receiving all the messages that were published before subscriber was actually started?

    Also, if a message's lifetime is set to be unlimited and there are no durable subscribers registered with the broker, does the broker still retain those messages until the message's destination is purged?

    And lastly, is there any way for an unregistered subscriber to receive the messages that haven't yet expired?

    Thanks again!
  • 3. Re: some durable subscribers don't receive any messages from broker
    jtahlborn Expert
    Currently Being Moderated
    883631 wrote:
    Thanks, I misinterpreted what it meant for a client to be "inactive". So just to be clear, is it completely coincidental that some subscribers are receiving all the messages that were published before subscriber was actually started?
    probably yes. that's up to the jms broker implementation. the only thing that is required by the jms spec is that a durable subscriber receive all messages sent after it subscribes.
    Also, if a message's lifetime is set to be unlimited and there are no durable subscribers registered with the broker, does the broker still retain those messages until the message's destination is purged?
    it is certainly not required to by the spec. it can drop those messages on the floor immediately. however, i wouldn't be surprised if certain jms brokers kept them around for a bit "just in case". (or if, like you mentioned, there is some delay in when the messages are discarded based on some background cleanup task scheduling)
    And lastly, is there any way for an unregistered subscriber to receive the messages that haven't yet expired?
    not according to the spec. again, however, actual jms broker implementations may have extra "features" such as this.
  • 4. Re: some durable subscribers don't receive any messages from broker
    nigeldeakin Explorer
    Currently Being Moderated
    Just to add to jtahlborn's comments:
    883631 wrote:
    Thanks, I misinterpreted what it meant for a client to be "inactive". So just to be clear, is it completely coincidental that some subscribers are receiving all the messages that were published before subscriber was actually started?
    By "started" do you mean "created". A durable subscription is created on the first call to createDurableSubscription(), and exists forever, accumulating messages, until you call unsubscribe(). These messages will be delivered to the consuming client just as soon as you call connection.start().

    If you create a durable subscription at the same time as a producer somewhere sends a message to the topic, it is a matter of timing as to whether the message is saved in the durable subscription. Obviously, once the first message has been saved than all subsequent messages must be as well.

    >
    Also, if a message's lifetime is set to be unlimited and there are no durable subscribers registered with the broker, does the broker still retain those messages until the message's destination is purged?
    The short answer is no. Don't think of messages as being stored in a topic in the same way as they are in a queue. Think of them as being stored in all the durable subscriptions on the topic.
    And lastly, is there any way for an unregistered subscriber to receive the messages that haven't yet expired?
    The word "unregistered" isn't used in JMS. Do you mean "non-durable"? If so then the answer is that a non-durable subscriber will only receive messages which were sent to the topic whilst the subscriber was actually connected. It won't receive any that were sent to the topic before then.


    >
    Thanks again!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points