I'm working on an application consisting of some modules. In one of those module someone created a topic producer that publishes messages on a topic, but this module hasn't a topic consumer to dequeue the messages. The topic producer sets the time-to-live property to 300000 milliseconds using setTimeToLive()
.
I expect that if there is no consumer, the messages expire within 300000 milliseconds and they are deallocated.
The application is deployed on Tomcat 6.0.36 and it uses an external ActiveMQ server to handle the queues and topics.
Monitoring ActiveMQ with Java VisualVM in the MBeans tab under the topic settings I see that the variable "Enqueue Count" grows, but I don't understand if the time-to-live settings took effect on these messages. I expected to see the counter "ExpiredCount" to increase, but it still remains fixed to 0.
Is there a way to understand if those messages still stay in memory or if they are deallocated?
Thank you very much!
EDIT:
I did some tests using j2ee tutorial examples on netbeans 7.3 using internal glassfish 3.1 as server, monitoring it with jvisualvm and all works as api says:
The JMS API provides no mechanism for browsing a topic. Messages usually disappear from a topic as soon as they appear: if there are no message consumers to consume them, the JMS provider removes them. Although durable subscriptions allow messages to remain on a topic > while the message consumer is not active, no facility exists for examining them.
I read that glassfish uses inside activeMQ so I hope that this is valid also for a standalone ActiveMQ server.
END EDIT.
topicSession.createSubscriber(...)
ortopicSession.createDurableSubscriber(...)
? – Beryllium