1

设置: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

在成功的例子中,我可以看到返回的delivery_mode 2。邮件未送达的原因可能是什么?

4

1 回答 1

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,现在我可以按预期发布和消费。

于 2013-09-02T09:49:27.953 回答