title: JMS topic time to live
body: <p>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 <code>setTimeToLive()</code>. </p>
  
  <p>I expect that if there is no consumer, the messages expire within 300000 milliseconds and they are deallocated.</p>
  
  <p>The application is deployed on Tomcat 6.0.36 and it uses an external ActiveMQ server to handle the queues and topics.</p>
  
  <p>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.</p>
  
  <p>Is there a way to understand if those messages still stay in memory or if they are deallocated?</p>
  
  <p>Thank you very much!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>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:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>I read that glassfish uses inside activeMQ so I hope that this is valid also for a standalone ActiveMQ server.</p>
  
  <p><strong>END EDIT.</strong></p>