0
votes

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

1
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 givenTim Bish
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? ibb.co/KDSdrMfCristian
Could it be that the messages don't have the expiration value set?Cristian
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
Enqueued count is meaningless for Topics as it doesn't tell you if the message was dropped just that a message arrivedTim Bish

1 Answers

1
votes

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).