title: How do I remove messages from a JBoss JMS Topic?
body: <p>I have configured my Topic in jbossmq-destinations-service.xml as follows:</p>
  
  <pre><code>&lt;mbean code="org.jboss.mq.server.jmx.Topic"
      name="jboss.mq.destination:service=Topic,name=myTopicName"&gt;
    &lt;depends optional-attribute-name="DestinationManager"&gt;
             jboss.mq:service=DestinationManager&lt;/depends&gt;
    &lt;depends optional-attribute-name="SecurityManager"&gt;
             jboss.mq:service=SecurityManager&lt;/depends&gt;
    &lt;attribute name="SecurityConf"&gt;
      &lt;security&gt;
        &lt;role name="guest" read="true" write="true" create="true"/&gt;
        &lt;role name="publisher" read="true" write="true" create="false"/&gt;
        &lt;role name="durpublisher" read="true" write="true" create="true"/&gt;
      &lt;/security&gt;
    &lt;/attribute&gt;
  &lt;/mbean&gt;
  </code></pre>
  
  <p>I can easily connect to the topic to publish messages by doing a JNDI lookup on the topic name and everything works fine.</p>
  
  <p>However, I want to be able to clear the messages at certain intervals since they may become out of date depending on some other system functionality but I can't find any examples or explanations of how to do this.</p>
  
  <p>The problem is that when I do a JNDI lookup on the topic it returns a org.jboss.mq.SpyTopic which does not have any functionality for removing messages or even to find out how many messages are on the topic. All the examples seem to suggest that org.jboss.mq.server.JMSTopic has all the functionality but I can't figure out how to convert a SpyTopic to a JMSTopic or how to set up the topic so that the JNDI lookup will return a JMSTopic.</p>
  
  <p>Can anyone help?<br>
  Thanks.</p>