php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55384 AMQP::consume()
Submitted: 2011-08-09 11:03 UTC Modified: 2011-08-29 20:55 UTC
From: peter dot colclough at toolstation dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.3.7RC4 OS: Ubuntu 10 , 64Bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: peter dot colclough at toolstation dot com
New email:
PHP Version: OS:

 

 [2011-08-09 11:03 UTC] peter dot colclough at toolstation dot com
Description:
------------
---
From manual page: http://www.php.net/amqpqueue.consume
---
Using this against a RabbitMQ server...

This is a very small snippet of very simple code. If you use the consume on a durable message on a durable queue, this just eats up memory, and kills teh machine, when it hits around 7k messages.
Using get() all is Ok. It looks like a memory leak somewhere in teh AMQP code....

Test script:
---------------
include_once('../config/config.php');
$nMessNum = 4000;
$nCount = 0;
$nTimeLimit = 600;

$nI = 0;
$sMessRoute = '';
while($nI++ < 10000){
$sMessRoute .= 'a';
} 

$nstart = microtime_float();
$amp = new AMQPConnection($RABBIT_SERVERS);
if($amp->connect()){
	echo('Connected to Host'."\n");
	// Declare a new exchange
	$options = AMQP_DURABLE;
	$ex = new AMQPExchange($amp,'stone_warren');
	$ex->declare('stone_warren', AMQP_EX_TYPE_FANOUT, AMQP_DURABLE);
  
	// Create a new queue
	$q = new AMQPQueue($amp);
	$q->declare('queue1',AMQP_DURABLE);

	// Bind it on the exchange to routing.key
	$ex->bind('queue1', 'routing.key');

	// consume a message to the exchange with a routing key...and ack it.
	$options = array(
		'min'=>1,
	   'max'=>10,
	   'ack'=>true
	);
	
	$nMsgCount = 0;
	$tsStart = time();
	   
        while(1){			// Forever
	   		
	   $nCount++;
	   // This dies soon... after about 7k messages
           $msg = $q->consume($options);
	   //$msg = $q->get(0);
	   echo(print_r($msg, true)."\n");
		
	   usleep(10000);
	   if((file_exists('consumer'.$nType.'.stop')) ||
              ((time() - $tsStart)  >               $nTimeLimit)){
		   break;
	    }
	}

}else{
	echo("Failed to connect \n");
} 
// END OF CODE


Expected result:
----------------
Should run forever, consuming messages placed on the queue by a similar process. Using get() I was able to process 23m messages over a 3 day period. Using consume(), I die in a matter of minutes.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-29 20:55 UTC] bjori@php.net
-Status: Open +Status: Bogus
 [2011-08-29 20:55 UTC] bjori@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Please file pecl extension issues in their own bug tracker, 
http://pecl.php.net/bugs/report.php?package=amqp
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC