RabbitMQ& php-amqplib - 消息未传递给消费者

时间:2013-08-30 10:17:37

标签: php centos rabbitmq

设置:Centos 6.2,RabbitMQ 3.1.3,PHP 5.4.3

我试图从php-amqlib运行演示脚本,具体来说 amqp_consumer_non_blocking.php& amqp_publisher.php

在一个控制台中我运行'php amqp_consumer_non_blocking.php',在另一个'php amqp_publisher.php这是一个测试'

'amqp_consumer_non_blocking.php'等待着:

< 60,20: Basic.consume
waiting for 60,21
waiting for a new frame
> 60,21: Basic.consume_ok

和'amqp_publisher.php'产生了这个:

< 60,40: Basic.publish
< [hex]:
0000  02 00 01 00 00 00 1A 00  3C 00 00 00 00 00 00 00   ........ <.......
0010  00 00 0E 90 00 0A 74 65  78 74 2F 70 6C 61 69 6E   .....te xt/plain
0020  02 CE                                              .Î

< [hex]:
0000  03 00 01 00 00 00 0E 54  68 69 73 20 69 73 20 61   .......T his is a
0010  20 74 65 73 74 CE                                   testÎ

< [hex]:
0000  01 00 01 00 00 00 0B 00  14 00 28 00 00 00 00 00   ........ ..(.....
0010  00 00 CE                                           ..Î

< 20,40: Channel.close
waiting for 20,41
waiting for a new frame

该消息似乎无法送达。

但是,我已经在另一个虚拟机(Centos 6.2,Rabbit 3.1.3,PHP 5.4.3)上运行这些脚本,并从'amqp_publisher.php'获取以下内容:

< 60,40: Basic.publish
< [hex]:
0000  02 00 01 00 00 00 1A 00  3C 00 00 00 00 00 00 00   ........ <.......
0010  00 00 0E 90 00 0A 74 65  78 74 2F 70 6C 61 69 6E   .....te xt/plain
0020  02 CE                                              .Î

< [hex]:
0000  03 00 01 00 00 00 0E 54  68 69 73 20 69 73 20 61   .......T his is a
0010  20 74 65 73 74 CE                                   testÎ

< [hex]:
0000  01 00 01 00 00 00 0B 00  14 00 28 00 00 00 00 00   ........ ..(.....
0010  00 00 CE                                           ..Î

< 20,40: Channel.close
waiting for 20,41
waiting for a new frame
> 20,41: Channel.close_ok
< [hex]:
0000  01 00 00 00 00 00 0B 00  0A 00 32 00 00 00 00 00   ........ ..2.....
0010  00 00 CE                                           ..Î

< 10,50: Connection.close
waiting for 10,51
waiting for a new frame
> 10,51: Connection.close_ok
closing socket

这来自消费者脚本:

< 60,20: Basic.consume 
waiting for 60,21
waiting for a new frame
> 60,21: Basic.consume_ok
waiting for any method
waiting for a new frame
> 60,60: Basic.deliver
waiting for a new frame
waiting for a new frame

--------
This is a test
--------
< [hex]:
0000  01 00 01 00 00 00 0D 00  3C 00 50 00 00 00 00 00   ........ <.P.....
0010  00 00 01 00 CE                                     ....Î

< 60,80: Basic.ack

在成功示例中,我可以看到回传的2的delivery_mode。可能是消息未送达的原因是什么?

1 个答案:

答案 0 :(得分:4)

Matthias Radestock向我指出了正确的方向,建议它看起来像资源问题,并建议我检查服务器日志。我在/var/log/rabbitmq/rabbit\@localhost.log中找到了以下内容:

=INFO REPORT==== 02-Sep-2013::12:48:48 ===
Disk free limit set to 1000MB

=INFO REPORT==== 02-Sep-2013::12:48:48 ===
Disk free space insufficient. Free bytes:588042240 Limit:1000000000

=WARNING REPORT==== 02-Sep-2013::12:48:48 ===
disk resource limit alarm set on node 'rabbit@localhost'.

**********************************************************
*** Publishers will be blocked until this alarm clears ***
**********************************************************

创建文件/etc/rabbitmq/rabbitmq.config并添加以下内容:

[{rabbit, [{disk_free_limit, 100000000}]}].

重启RabbitMQ&amp;现在我可以发布&amp;按预期消费。