title: Expire Messages on ActiveMQ when there are not subscribers
body: <p>When adding messages to a queue in an ActiveMQ broker where there is no subscriber the queue fills up and eventually the producer thread hangs, unable to publish any more messages.</p>
  
  <p>In an attempt to resolve the problem I set an expiry on the messages, thinking that this would free up memory but unfortunately this doesn't work. Does anyone know how I can resolve the issue?</p>
  
  <p>My broker ActiveMQ version is 5.7 and broker definition is:</p>
  
  <pre><code>&lt;bean id="mqBroker" class="org.apache.activemq.broker.BrokerService" init-method="start" destroy-method="stop"&gt;
      &lt;property name="brokerName" value = "mainBroker"/&gt;
      &lt;property name="persistent" value="false"/&gt;
      &lt;property name="useJmx" value="false"/&gt;
      &lt;property name="transportConnectorURIs"&gt;
          &lt;list&gt;
              &lt;value&gt;tcp://localhost:7000&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Looking in JConsole when it's unable to publish any more messages to the broker the memory usage looks fine (0% usage) and expired count=published count. </p>
  
  <p>The code I'm using to publish messages is with spring integration:</p>
  
  <pre><code>&lt;jms:outbound-channel-adapter
      channel="jsonChannel"
      connection-factory="jmsConnectionFactory"
      pub-sub-domain="false"
      destination-name="MY_QUEUE"
      time-to-live="60000"
      wxplicit-qos-enabled="true" /&gt;
  </code></pre>