0

I'm building a software solution which creates JMS topics per new category of something. The topic is created when the first round of data is integrated and must be comunicated. Durable subscriptions to that topic are created by consumers, but only some time after the category and first data are created. All the data belonging to the category is sent as messages to the consumers, so that they are updated too.

Between the moment when the category is created, and when the durable subscriptions are created, it would be better if the messages are discarded. The consumer first does an initial sync of the existing data, then created the durable subscription and listens for create/update messages.

One option would be to let the consumers create the topic when registering the first durable subscription. In the meantime, if data is added to the category, it is not sent by the produces, thus not creating the topic too.

Another option would be to discard the messages if no consumers exist. I'm not talking about active consumers, I'm talking about no consumers at all. Any idea if this can be implemented? Since there are no durable/non-durable subscriptions for the topic, I was expecting that the messages would be discarded automatically, but I was wrong.

Which option would you choose?

If you look at the image below you will see a topic which never had subscribers with 4498 messages enqueued. Am I interpreting this information in a wrong manner?

enter image description here

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Cristian
  • 417
  • 1
  • 9
  • 18
  • Given that the broker does indeed discard when no consumers and no existing durable subscriptions I'd say your test is likely wrong but we can't tell from the info given – Tim Bish Feb 05 '20 at 13:36
  • If you open the imagine in the link, you will see a topic which never had subscribers with 4498 messages enqueued. Am I interpreting this informations in a wrong manner? https://ibb.co/KDSdrMf – Cristian Feb 05 '20 at 13:42
  • Could it be that the messages don't have the expiration value set? – Cristian Feb 05 '20 at 14:03
  • I set the delivery mode to non-persistent and the expiration value to 60.000. The number of enqueued messages keeps going up in the ActiveMQ console. – Cristian Feb 05 '20 at 14:57
  • Enqueued count is meaningless for Topics as it doesn't tell you if the message was dropped just that a message arrived – Tim Bish Feb 05 '20 at 20:47
  • I will first let the topic fill up with enqueued messages, then some time later I will create a first consumer for testing purposes. If nothing comes, it means that the topic is actually empty. I will post another reply tomorrow. Thanks. – Cristian Feb 05 '20 at 21:03

1 Answers1

2

Messages sent to a topic when no subscriptions exist (whether durable or not) should be discarded. That's the expected behavior.

The "Messages Enqueued" metric visible on the web console does not mean what you think it means. This metric simply indicates the total number of messages sent to the topic since the last restart. It doesn't indicate how many messages have been retained in subscriptions on that topic (if any).

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43