Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<chan
程序员文章站
2022-07-10 19:10:50
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=404, reply-text=NOT_FOUND - no queue ‘queue_cms_postpage’ in vhost ‘/’, class-id=50, method-id=10)今下午遇到的一个bug,花费较长时间网上搜寻,加询问最终解...
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no queue ‘queue_cms_postpage’ in vhost ‘/’, class-id=50, method-id=10)
今下午遇到的一个bug,花费较长时间网上搜寻,加询问最终解决,记录一下。
bug:org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[queue_cms_postpage]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:711) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:588) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:964) [spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: java.io.IOException: null
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:126) ~[amqp-client-5.1.2.jar:5.1.2]
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:122) ~[amqp-client-5.1.2.jar:5.1.2]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:144) ~[amqp-client-5.1.2.jar:5.1.2]
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:991) ~[amqp-client-5.1.2.jar:5.1.2]
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:52) ~[amqp-client-5.1.2.jar:5.1.2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:981) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at com.sun.proxy.$Proxy107.queueDeclarePassive(Unknown Source) ~[na:na]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:690) ~[spring-rabbit-2.0.3.RELEASE.jar:2.0.3.RELEASE]
... 3 common frames omitted
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no queue 'queue_cms_postpage' in vhost '/', class-id=50, method-id=10)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-5.1.2.jar:5.1.2]
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) ~[amqp-client-5.1.2.jar:5.1.2]
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:494) ~[amqp-client-5.1.2.jar:5.1.2]
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:288) ~[amqp-client-5.1.2.jar:5.1.2]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:138) ~[amqp-client-5.1.2.jar:5.1.2]
... 12 common frames omitted
经过上的搜寻有这么几种回答:
第一种:权限问题。问题在in vhost '/'
在RabbitMQ 管理界面,把Exchanges,和Queues两个栏目的Virtual host 从"ALL",改为"/"即可。
第二种:由于rabbitmq 消费者 监听消息队列时, 消息队列没有创建 导致上面的异常,这个我当时是创建了的。
第三种:第一次创建rabbitmq交换机后,更改交换机类型,继续创建时出现。原因时存在同名的交换机。比如rabbitmq服务器中已经存在direct类型的交换机(name=“exchange”),你再创建一个同名的但是类型为fanout时就会出错,需要更换名字后再创建。
而我的也没有重复,这时我就纳闷了。。。。
就在这时我突然发现了一个不寻常的地方,
@RabbitListener(queues = {RabbitConfig.QUEUE_CMS_POSTPAGE})
好像没什么错,,,
yml配置中:
xuecheng:
mq:
#cms客户端监控的队列名称(不同的客户端监控的队列不能重复)
queue: queue_cms_postpage_01
routingKey: 5a751fab6abb5044e0d19ea1
我看这的时候,我????????
@Configuration
public class RabbitConfig {
//队列bean的名称
public static final String QUEUE_CMS_POSTPAGE = "queue_cms_postpage";
//交换机的名称
public static final String EX_ROUTING_CMS_POSTPAGE="ex_routing_cms_postpage";
//队列的名称
@Value("${xuecheng.mq.queue}")
public String queue_cms_postpage_name;
//routingKey 即站点Id
@Value("${xuecheng.mq.routingKey}")
public String routingKey;
再一看RabbitMQ配置文件,祖安的话语涌上心头,这个监听的队列竟然写成了队列bean
的名称了!我真是日了狗啊。
@RabbitListener(queues = {"${xuecheng.mq.queue}"})
改成这样终于成功了。。
本文地址:https://blog.csdn.net/weixin_45954637/article/details/107498444
上一篇: Java基础语法之类和对象理解
推荐阅读
-
RabbitMQ系列--异常:com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<
-
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<chan
-
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<chan