记一次项目启动报错(Springboot)
Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg ‘type’ for exchange ‘exchangeName’ in vhost ‘/’: received ‘direct’ but current is ‘topic’, class-id=40, method-id=10)
报错截图
大概意思是交换机类型错误,用到的是direct,但当前是topic。
看到这里第一时间去rabbitmqconfig 里看看,
/**
* 配置交换机
*/
@Bean
public Exchange easywExchange(){
return ExchangeBuilder.topicExchange(rabbitmqProperties.getExchange()).durable(true).build();
}
没毛病,的确是topic类型,那direct又是哪来的呢???网上也没有可行的方案,只能自己解决了,把生产者消费者都看了一遍发现了问题所在,罪魁祸首就是
@RabbitListener(bindings = @QueueBinding(
value = @Queue("#{rabbitmqProperties.queueName}"),
exchange = @Exchange(value = "#{exchangeName}",type = "topic")),ackMode = "MANUAL")
exchange = @Exchange(value = “#{exchangeName}”,type = “topic”)
如果注解中不加type =“topic” 默认是direct类型
果断改掉重启服务,发现还特么报错,想起之前创建的exchange没有删除,登陆mq客户端,delete掉,再重启。
解决!!!!
ps:这个问题可能还会引起自动创建队列失败
failed to check/redeclare auto-delete queue(s) 自己记录下遇到的坑,如果有人和我一样的问题可以参考下