Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'me
在启动RabbitMQ消费端的时候报错:Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'messageChange' in vhost '/': received 'fanout' but current is 'direct', class-id=40, method-id=10)
详细信息如下:
F:\jdk1.8.0_151\bin\java.exe "-javaagent:E:\IntelliJ IDEA 2019.2.1\lib\idea_rt.jar=56252:E:\IntelliJ IDEA 2019.2.1\bin" -Dfile.encoding=UTF-8 -classpath F:\jdk1.8.0_151\jre\lib\charsets.jar;F:\jdk1.8.0_151\jre\lib\deploy.jar;F:\jdk1.8.0_151\jre\lib\ext\access-bridge-64.jar;F:\jdk1.8.0_151\jre\lib\ext\cldrdata.jar;F:\jdk1.8.0_151\jre\lib\ext\dnsns.jar;F:\jdk1.8.0_151\jre\lib\ext\jaccess.jar;F:\jdk1.8.0_151\jre\lib\ext\jfxrt.jar;F:\jdk1.8.0_151\jre\lib\ext\localedata.jar;F:\jdk1.8.0_151\jre\lib\ext\nashorn.jar;F:\jdk1.8.0_151\jre\lib\ext\sunec.jar;F:\jdk1.8.0_151\jre\lib\ext\sunjce_provider.jar;F:\jdk1.8.0_151\jre\lib\ext\sunmscapi.jar;F:\jdk1.8.0_151\jre\lib\ext\sunpkcs11.jar;F:\jdk1.8.0_151\jre\lib\ext\zipfs.jar;F:\jdk1.8.0_151\jre\lib\javaws.jar;F:\jdk1.8.0_151\jre\lib\jce.jar;F:\jdk1.8.0_151\jre\lib\jfr.jar;F:\jdk1.8.0_151\jre\lib\jfxswt.jar;F:\jdk1.8.0_151\jre\lib\jsse.jar;F:\jdk1.8.0_151\jre\lib\management-agent.jar;F:\jdk1.8.0_151\jre\lib\plugin.jar;F:\jdk1.8.0_151\jre\lib\resources.jar;F:\jdk1.8.0_151\jre\lib\rt.jar;F:\workspace\rabbitmqDemo\rabbitmqConsumer02\target\test-classes;F:\repository_ssh\org\springframework\boot\spring-boot-starter-logging\2.1.0.RELEASE\spring-boot-starter-logging-2.1.0.RELEASE.jar;F:\repository_ssh\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;F:\repository_ssh\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;F:\repository_ssh\org\apache\logging\log4j\log4j-to-slf4j\2.11.1\log4j-to-slf4j-2.11.1.jar;F:\repository_ssh\org\apache\logging\log4j\log4j-api\2.11.1\log4j-api-2.11.1.jar;F:\repository_ssh\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;F:\repository_ssh\com\rabbitmq\amqp-client\5.7.0\amqp-client-5.7.0.jar;F:\repository_ssh\org\slf4j\slf4j-api\1.7.26\slf4j-api-1.7.26.jar xyfer.Consumer01
java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:129)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:125)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:147)
at com.rabbitmq.client.impl.ChannelN.exchangeDeclare(ChannelN.java:783)
at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.exchangeDeclare(AutorecoveringChannel.java:242)
at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.exchangeDeclare(AutorecoveringChannel.java:232)
at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.exchangeDeclare(AutorecoveringChannel.java:212)
at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.exchangeDeclare(AutorecoveringChannel.java:217)
at xyfer.Consumer01.main(Consumer01.java:30)
12 Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'messageChange' in vhost '/': received 'fanout' but current is 'direct', class-id=40, method-id=10)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:502)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:293)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:141)
... 6 more
19 Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'messageChange' in vhost '/': received 'fanout' but current is 'direct', class-id=40, method-id=10)
at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:522)
at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:346)
at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:182)
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:114)
at com.rabbitmq.client.impl.AMQConnection.readFrame(AMQConnection.java:672)
at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:48)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:599)
at java.lang.Thread.run(Thread.java:748) Process finished with exit code -1
仔细看一下报错信息:Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'messageChange' in vhost '/': received 'fanout' but current is 'direct', class-id=40, method-id=10)
大概意思是交换机的类型不匹配,消费端应该收到名称为“messageChange”,类型为“fanout”的交换机发送的消息,但是当前RabbitMQ中存在的名称为“messageChange”的交换机的类型却是“direct”,所以交换机的类型不匹配。
打开RabbitMQ可以看到确实是这样:

目前有两种解决方式:
一、更改消费端代码中声明的交换机名称即可;
二,把RabbitMQ中的同名却不同类型的交换机删除即可;
消费端代码如下,交换机名称为“messageChange”,类型为“fanout”;
package xyfer; import com.rabbitmq.client.*; import java.io.IOException;
import java.util.concurrent.TimeoutException; public class Consumer02 {
//Publish/subscribe发布订阅模式
private static final String QUEUE_SMS ="queueSms";
private static final String EXCHANGE = "messageChange"; 同名
public static void main(String[] args) {
Connection connection = null;
Channel channel = null;
try {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("127.0.0.1");
connectionFactory.setPort(5672);
connection = connectionFactory.newConnection();
channel = connection.createChannel();
//通道绑定交换机
/**
* 参数明细
* 1、交换机名称
* 2、交换机类型,fanout、topic、direct、headers
*/
//Publish/subscribe发布订阅模式
channel.exchangeDeclare(EXCHANGE, BuiltinExchangeType.FANOUT); 不同类型
//通道绑定队列
/**
* 声明队列,如果Rabbit中没有此队列将自动创建
* param1:队列名称
* param2:是否持久化
* param3:队列是否独占此连接
* param4:队列不再使用时是否自动删除此队列
* param5:队列参数
* String queue, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments
*
*/
channel.queueDeclare(QUEUE_SMS,true,false,false,null);//通道绑定短信队列
//交换机和队列绑定
/**
* 参数明细
* 1、队列名称
* 2、交换机名称
* 3、路由key
*/
//Publish/subscribe发布订阅模式
channel.queueBind(QUEUE_SMS,EXCHANGE,"");
DefaultConsumer consumer = new DefaultConsumer(channel) {
/**
* 消费者接收消息调用此方法
* @param consumerTag 消费者的标签,在channel.basicConsume()去指定
* @param envelope 消息包的内容,可从中获取消息id,消息routingkey,交换机,消息和重传标志
(收到消息失败后是否需要重新发送)
* @param properties
* @param body
* @throws IOException
* String consumerTag, Envelope envelope, BasicProperties properties, byte[] body
*/
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
//交换机
String exchange = envelope.getExchange();
//路由key
String routingKey = envelope.getRoutingKey();
envelope.getDeliveryTag();
String msg = new String(body,"utf-8");
System.out.println("mq收到的消息是:"+msg );
} };
System.out.println("消费者启动成功!");
channel.basicConsume(QUEUE_SMS,true,consumer); } catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
}
}
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'me的更多相关文章
- rabbitMQ报错:Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method:
1.输入的机器的 IP:15672进入Raabitmq的登陆管理界面 点击admin,进去点击set permission ok, 在运行应该就不会包这个错了
- RabbitMQException com.rabbitmq.client.ShutdownSignalException: connection error; protocol meth
异常1 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ...
- Caused by: com.rabbitmq.client.ShutdownSignalException: connection error
周五下午的时候升级了一个环境,跑了批处理sh升级脚本后,启动时报下列错误: INFO | jvm 1 | 2017/02/24 17:39:09 | java.io.IOException INFO ...
- Amqp整合com.rabbitmq.client.ShutdownSignalException: channel error; protocol method异常处理
java.io.IOException at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:126) at com.rabbitmq ...
- rabbitmq 出现 com.rabbitmq.client.ShutdownSignalException: , ..................
-classpath "C:\Program Files\Java\jdk1.8.0_144\jre\lib\charsets.jar;C:\Program Files\Java\jdk1. ...
- rabbitmq系列问题解决:406, "PRECONDITION_FAILED - inequivalent arg 'durable'
1. 安装rabbitmq,查看官网文档: https://www.rabbitmq.com/#getstarted 由于我是先安装了rabbitmq后自己随手创建了queue,后面又按照官方给的&q ...
- com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no queue 'springCloudBus.anonymous.6Xa99MDZTJyHKdPqMyoVEA' in
项目启动报此异常,解决方式:用root权限登陆rabbitmq,admin处添加vhost
- Caused by: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker logfile.的几种原因
环境:centos 7+ 1.查看用户是否存在 进入安装目录使用./sbin/rabbitmqctl list_users查看是否存在用户 比如:./usr/local/rabbitmq/rabbit ...
- RabbitMQ inequivalent arg 'durable' for exchange 'csExchange' in vhost '/': received
错误:inequivalent arg 'durable' for exchange 'csExchange' in vhost '/': received 使用不同的MQ客户端时,常常会出现以上错误 ...
随机推荐
- gsoap使用
一. 安装gsoap 下载地址:http://sourceforge.net/projects/gsoap2/files/ 解压安装:./configure --prefix=/usr/local/g ...
- NSUserdefaults清除存储内容
有两种方式 方式一:找到所有的key,然后删除对象 /** * 清除所有的存储本地的数据 */ - (void)clearAllUserDefaultsData { NSUserDefaults * ...
- 最全的linux基础命令
第1章 linux命令 1.1 线上查询及帮助命令 help命令*** help前面接你要查询的命令:例如ls [root@server02 ~]# ls --help 用法:ls [选项]... [ ...
- 【VMware】The VMX process exited permaturely
问题现象: 开启虚拟机时出现如图问题:虚拟机退出过早 解决方法: 以管理员身份运行cmd,输入netsh winsock reset ,回车然后重启
- DHCP服务相关实验
一.DHCP 相关介绍 1.dhcp服务相关 软件名: dhcp #DHCP服务软件包 dhcp-common #DHCP命令软件包(默认已安装) 服务名: dhcpd #DHCP服务名 dhcrel ...
- SpringBoot电商项目实战 — 前后端分离后的优雅部署及Nginx部署实现
在如今的SpringBoot微服务项目中,前后端分离已成为业界标准使用方式,通过使用nginx等代理方式有效的进行解耦,并且前后端分离会为以后的大型分布式架构.弹性计算架构.微服务架构.多端化服务(多 ...
- UWP 从创建到发布流程一栏
# UWP的产品新建到发布流程一览 1,UWP开发特性 U: Universal(通用) W: Windows P: Plantform(平台) 运行在Windows10设备 比WPF更加多样化和完善 ...
- JavaScrip 之 DOM
DOM 树 HTML 文档的骨干是标签. 根据文档对象模型(DOM),每个HTML标签都是一个对象,同样标签内的文本也是一个对象.因此这些对象都可通过 JavaScript 操作 如果文档中有空格(就 ...
- 「SAP技术」SAP MM 明明有维护源清单,还是不能下PO?
SAP MM 明明有维护源清单,还是不能下PO? 下午收到用户报错说,创建采购订单失败,报错 :Material ### not included in source list despite sou ...
- Elasticsearch7.5.0源码编译
环境及工具 JDK12 Gradle5.6.2 GIT 源码及预处理 到github将代码clone下来,可以根据自己的需求来获取版本,例如 git checkout v7.5.0 提前下载gradl ...