gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 17:18:08 26 4
gpt4 key购买 nike

设置: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。邮件未送达的原因可能是什么?

最佳答案

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

关于php - RabbitMQ 和 php-amqplib - 消息未传递给消费者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18530495/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com