title: ActiveMQ not returning message when queue has n number of pending messages
body: <p>Environment/Background:</p>
  
  <p>Using PHP Stomp library to send and receive message from ActiveMQ (v5.4.3).</p>
  
  <p>Steps:</p>
  
  <ol>
  <li>Client sends a message with reply-to &amp; correlation-id headers to request queue (say /queue/request)</li>
  <li>Subscribe to the response queue (say /queue/response)</li>
  <li>Read frame</li>
  <li>ack</li>
  <li>unsubscribe</li>
  </ol>
  
  <p>The above steps works fine when there is no pending message or pending message &lt; n. In my case, n =200. When the number of pending message is > 200, the message is not delivered. The process waits till timeout and finally timeout without response. I can see the message (using admin UI) after timeout. Here is the code that I'm using for this case:</p>
  
  <pre><code>&lt;?php
  
  // make a connection
  $con = new Stomp("tcp://localhost:61616");
  // Set read timeout.
  $con-&gt;setReadTimeout(10);
  
  // Prepare request variables.
  $correlation_id = rand();    
  $request_queue = '/queue/com.domain.service.request';
  $response_queue = '/queue/com.domain.service.response';
  $selector =  "JMSCorrelationID='$correlation_id'";
  $headers = array('correlation-id' =&gt; $correlation_id, 'reply-to' =&gt; $response_queue);
  $message = '&lt;RequestBody&gt;&lt;/RequestBody&gt;';
  
  // send a message to the queue.
  $con-&gt;send($request_queue, $message, $headers);
  
  // subscribe to the queue
  $con-&gt;subscribe($response_queue, array('selector' =&gt; $selector, 'ack' =&gt; 'auto'));
  
  // receive a message from the queue
  $msg = $con-&gt;readFrame();
  
  // do what you want with the message
  if ( $msg != null) {
      echo "Received message with body\n";
      var_dump($msg);
      // mark the message as received in the queue
      $con-&gt;ack($msg);
  } else {
      echo "Failed to receive a message\n";
  }
  unset($con);
  </code></pre>
  
  <p>Other findings:</p>
  
  <ol>
  <li><p>Sending messages from one file (say from sender.php) and receive using another script (say receiver.php) working fine.</p></li>
  <li><p>Allows to send more than 1000 message in the same request queue(and eventually processed and placed in response queue). So it doesn't look like memory issue.</p></li>
  <li><p>Funny enough, while waiting for timeout, if I browse the queue on admin UI, I get the response.</p></li>
  <li><p>By default, the stomp broker that I use set the prefetch size to 1.</p></li>
  </ol>