概述
2019独角兽企业重金招聘Python工程师标准>>>
- 系统 deepin
- rabbitmq 版本,RabbitMQ 3.6.10, Erlang 20.0.1
死信队列demo测试
php delayed_message.php
报错1
PHP Fatal error: Uncaught PhpAmqpLibExceptionAMQPProtocolConnectionException: COMMAND_INVALID - unknown exchange type 'x-delayed-message' in /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php:689 Stack trace: #0 [internal function]: PhpAmqpLibConnectionAbstractConnection->connection_close(Object(PhpAmqpLibWireAMQPReader)) #1 /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(207): call_user_func(Array, Object(PhpAmqpLibWireAMQPReader)) #2 /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(348): PhpAmqpLibChannelAbstractChannel->dispatch('10,50', 'x01xF7;COMMAND_INVA...', NULL) #3 /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(614): PhpAmqpLibChannelAbstractChannel->wait() #4 /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(225): PhpAmqpLibConnectionAbstractConnection->wait_channel(1, 0) in /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php on line 689
原因是死信队列插件未安装
安装办法
命令安装
sudo rabbitmq-plugins enable rabbitmq_delayed_message_exchange
提示:
Error: The following plugins could not be found:
rabbitmq_delayed_message_exchange
意思是插件不存在
命令查看已有插件
sudo rabbitmq-plugins list
*号是已开启,同时发现未开启的插件中也没有deady的插件,需要自己手动去官方下载
地址
https://www.rabbitmq.com/community-plugins.html
找到插件,发现只支持3.6以上版本,本地环境刚好合适
然后下载3.6的插件,解压出来文件
rabbitmq_delayed_message_exchange-20171215-3.6.x.ez
之后文件手动放到rabbitmq-server的插件目录下即可
插件目录地址为:
/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10/plugins
放入文件之后
再次开启插件
sudo rabbitmq-plugins enable rabbitmq_delayed_message_exchange
成功安装,报错消失.....
报错2如下.
继续执行官方文件
php delayed_message.php
发现还是报错:
PHP Fatal error: Uncaught PhpAmqpLibExceptionAMQPProtocolChannelException: PRECONDITION_FAILED - unknown delivery tag 1 in /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AMQPChannel.php:188 Stack trace: #0 [internal function]: PhpAmqpLibChannelAMQPChannel->channel_close(Object(PhpAmqpLibWireAMQPReader)) #1 /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(207): call_user_func(Array, Object(PhpAmqpLibWireAMQPReader)) #2 /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(348): PhpAmqpLibChannelAbstractChannel->dispatch('20,40', 'x01x96,PRECONDITION...', NULL) #3 /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/demo/delayed_message.php(86): PhpAmqpLibChannelAbstractChannel->wait() #4 {main} thrown in /var/www/html/rabbitmq/vendor/php-amqplib/php-amqplib/PhpAmqpLib/Channel/AMQPChannel.php on line 188
小编实在不知道这个啥意思,找了好久资料发现
可能是设置错误
//如果设置了这个代码 $message->delivery_info['channel']->basic_nack($message->delivery_info['delivery_tag']);
消费端的代码 no_acked熟悉必须是false
$channel->basic_consume('delayed_queue', '', false, false, false, false, 'process_message');
否则报错
转载于:https://my.oschina.net/osgrace/blog/1814310
最后
以上就是纯情楼房为你收集整理的rabbitmq AMQP 死信队列报错COMMAND_INVALID,PRECONDITION_FAILED的全部内容,希望文章能够帮你解决rabbitmq AMQP 死信队列报错COMMAND_INVALID,PRECONDITION_FAILED所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复