title: ActiveMQ Pending messages
body: <p>I have a problem with ActiveMQ similar to this one:
  <a href="http://activemq.2283324.n4.nabble.com/Messages-stuck-in-pending-td4617979.html" rel="nofollow noreferrer">http://activemq.2283324.n4.nabble.com/Messages-stuck-in-pending-td4617979.html</a>
  and already tried the solution posted here.</p>
  
  <p>Some messages seem to get stuck on the queue and can sit there for literally days without being consumed. I have more than enough consumers that are free most of the time, so it's not an issue of "saturation" of consumers.</p>
  
  <p>Upon restart of the ActiveMQ SOME of the pending messages are consumed right away. Just a moment ago I had situation where I had 25 free consumers avaiable for queue (they are visible in the admin panel) with 7 of those "stuck" messages. Four of them were consumed right away but other 3 are still stuck. The other strange thing is - new messages kept coming to queue and were consumed right away, while the 3 old ones were still stuck.</p>
  
  <p>On the consumer side my config in spring looks as follows:</p>
  
  <pre><code>&lt;jms:listener-container concurrency="${activemq.concurrent.consumers}" prefetch="1"&gt;
      &lt;jms:listener destination="queue.request" response-destination="queue.response" ref="requestConsumer" method="onRequest"/&gt;
  &lt;/jms:listener-container&gt;
  
  &lt;bean id="prefetchPolicy" class="org.apache.activemq.ActiveMQPrefetchPolicy"&gt;
          &lt;property name="queuePrefetch" value="1" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory"&gt;
      &lt;property name="brokerURL" value="${activemq.broker.url}?initialReconnectDelay=100&amp;amp;maxReconnectDelay=10000&amp;amp;startupMaxReconnectAttempts=3"/&gt;
      &lt;property name="prefetchPolicy" ref="prefetchPolicy"/&gt;
  &lt;/bean&gt;
  </code></pre>