[rabbitmq-discuss] Script/Connection not getting terminated.

tluck tilak.chauhan at ymail.com
Fri Jun 7 11:13:42 BST 2013


Hi MK,

>> Something in your code rejects messages with unknown delivery tag. This
>> causes
the channel to be closed.

Even if a channel is being closed then why script has not been terminated ?.
I'm using `basic_get` method to consume messages.

>> Can you post a fragment of your code that rejects messages and also be
>> more specific about which PHP library you use?

https://github.com/tnc/php-amqplib -- This is the php library I'm using.

Here is my code sample :

$connection = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); 
$channel = $connection->channel(); 
$channel->queue_declare($queue, false, true, false, false); 
$channel->exchange_declare('myexchange', 'direct', true, true, false); 
$channel->queue_bind('myqueue', $exchange, $queue); 

while ($msg = $channel->basic_get($queue)) {
    consumerMessage($msg, $connection, $channel);
}

$channel->close(); 
$connection->close(); 

function consumerMessage($msg, $connection, $channel){ 
        $data = json_decode($msg->body, true);
        IF(thisConsumerIsNotAllowedToConsumeThisMessage){
            $channel->basic_ack($msg->delivery_info['delivery_tag']);
            return;
        }

	DoAllDataProcessing($data);
	$channel->basic_ack($msg->delivery_info['delivery_tag']);
	return;
} 


Thanks,
T.luck

 




--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/Script-Connection-not-getting-terminated-tp27265p27271.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list