title: Always ensure only last 10 messages in ActiveMQ Topic
body: <p>We have an issue in ActiveMQ where we have a huge number of messages not dropping off topics.
  The topics are set to non-persistent, non-durable.
  Our Activemq.xml file is </p>
  
  <pre><code>&lt;beans&gt;
  
    &lt;broker xmlns="http://activemq.apache.org/schema/core" useJmx="false" persistent="false"&gt;
  
  &lt;!--
      &lt;persistenceAdapter&gt;
        &lt;journaledJDBC journalLogFiles="5" dataDirectory="../data"/&gt;
      &lt;/persistenceAdapter&gt;
  --&gt;
  
          &lt;transportConnectors&gt;
              &lt;transportConnector uri="vm://localhost"/&gt;
          &lt;/transportConnectors&gt;
  
    &lt;/broker&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and our topic definition in messaging-config.xml is</p>
  
  <pre><code>&lt;destination id="traceChannel"&gt;
  
      &lt;properties&gt;
  
          &lt;network&gt;
          &lt;session-timeout&gt;10&lt;/session-timeout&gt;
      &lt;/network&gt;
  
          &lt;server&gt;
              &lt;message-time-to-live&gt;10000&lt;/message-time-to-live&gt;
              &lt;durable&gt;false&lt;/durable&gt;
              &lt;durable-store-manager&gt;flex.messaging.durability.FileStoreManager&lt;/durable-store-manager&gt;
          &lt;/server&gt;
  
          &lt;jms&gt;
              &lt;destination-type&gt;Topic&lt;/destination-type&gt;
              &lt;message-type&gt;javax.jms.ObjectMessage&lt;/message-type&gt;
              &lt;connection-factory&gt;ConnectionFactory&lt;/connection-factory&gt;
              &lt;destination-jndi-name&gt;dynamicTopics/traceTopic&lt;/destination-jndi-name&gt;
              &lt;delivery-mode&gt;NON_PERSISTENT&lt;/delivery-mode&gt;
              &lt;message-priority&gt;DEFAULT_PRIORITY&lt;/message-priority&gt;
              &lt;acknowledge-mode&gt;AUTO_ACKNOWLEDGE&lt;/acknowledge-mode&gt;
              &lt;transacted-sessions&gt;false&lt;/transacted-sessions&gt;
              &lt;initial-context-environment&gt;
                  &lt;property&gt;
                      &lt;name&gt;Context.INITIAL_CONTEXT_FACTORY&lt;/name&gt;
                      &lt;value&gt;org.apache.activemq.jndi.ActiveMQInitialContextFactory&lt;/value&gt;
                  &lt;/property&gt;
                  &lt;property&gt;
                      &lt;name&gt;Context.PROVIDER_URL&lt;/name&gt;
                      &lt;value&gt;tcp://localhost:61616&lt;/value&gt;
                  &lt;/property&gt;
              &lt;/initial-context-environment&gt;
          &lt;/jms&gt;
      &lt;/properties&gt;
  
      &lt;channels&gt;
          &lt;channel ref="rtmps" /&gt;
      &lt;/channels&gt;
  
      &lt;adapter ref="trace" /&gt;
  
  &lt;/destination&gt;
  </code></pre>
  
  <p>What I am trying to achieve is that only the last 10 messages be on the topics at any one time as leaving it running overnight results in over 150K messages on the topic even though it should only be holding a very small number.</p>