springboot整合rabbitmq遇到上面报错,截取下报错的堆栈块如下:
Caused by: org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.amqp.rabbit.config.internalRabbitListenerEndpointRegistry'; nested exception is org.springframework.amqp.AmqpIllegalStateException: Fatal exception on listener startup
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:50)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:348)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:151)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:114)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:879)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:372)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5135)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 27 more
Caused by: org.springframework.amqp.AmqpIllegalStateException: Fatal exception on listener startup
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doStart(SimpleMessageListenerContainer.java:844)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.start(AbstractMessageListenerContainer.java:592)
at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.startIfNecessary(RabbitListenerEndpointRegistry.java:279)
at org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry.start(RabbitListenerEndpointRegistry.java:235)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:175)
... 44 more
Caused by: org.springframework.amqp.rabbit.listener.QueuesNotAvailableException: Cannot prepare queue for listener. Either the queue doesn't exist or the broker will not allow us to use it.
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:546)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1338)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[X01]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:619)
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:518)
... 2 more
Caused by: java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:105)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:101)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:123)
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:884)
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:60)
at org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl.queueDeclarePassive(PublisherCallbackChannelImpl.java:358)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:929)
at com.sun.proxy.$Proxy144.queueDeclarePassive(Unknown Source)
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:598)
... 3 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=404, reply-text=NOT_FOUND - no queue 'X01' in vhost '/', class-id=50, method-id=10)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:32)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:360)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:225)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117)
... 13 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=404, reply-text=NOT_FOUND - no queue 'X01' in vhost '/', class-id=50, method-id=10)
at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:483)
at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:320)
at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:143)
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:90)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:559)
找到堆栈中的关键信息作为本文的标题,这个堆栈中再一个扣人心悬的关键字就是reply-code=404.
分析
这个错误的堆栈信息是集成了rabbitmq的springboot项目再启动的时候报的,再报错中,它找不到的队列名字叫X01,这个队列再该项目中是作为消费者,来监听的队列。所以这个队列应该是再项目启动的时候与项目的消费监听进行绑定,如果绑定的时候发现,这个队列不存在,那么项目应该会自动的再rabbitmq中创建该队列,所以理论上应该不存在找不到队列这个问题的。
继续查看错误堆栈信息,发现错误信息
Failed to declare queue(s):[X01]
Cannot prepare queue for listener. Either the queue doesn't exist or the broker will not allow us to use it.
这个错误的始作俑者应该是上面的错误的第一行导致的,声明队列失败,导致后面监听无法绑定,导致了404。
上网查看,找到第一个解决方案,说是连接版本的问题,但是我并没有使用它提供的那个连接器,所以这个对我应该并不适用。
https://help.mulesoft.com/s/article/RabbitMQ-connector-fails-to-reconnect-after-reply-code-404-reply-text-NOT-FOUND-home-node-RabbitMQNodeName-of-durable-queue-exception
继续查找原因:
https://www.jianshu.com/p/1c4c42ff5114
找到这篇方案,但是查看自己的情况,当前的rabbitmq并没有宕机,而且重启客户端所在的应用也没有成功。
再探究竟
被其他的事情打断了下,3天之后,重新启动项目,想看看之前出现的错误,发现此时堆栈信息已经更换,报出来的堆栈信息如下:
2020-01-06 11:16:46 [ERROR] o.s.a.r.l.SimpleMessageListenerContainer#redeclareElementsIfNecessary:1138 - Failed to check/redeclare auto-delete queue(s).
org.springframework.amqp.AmqpIOException: java.io.IOException
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:71) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.connection.RabbitAccessor.convertRabbitAccessException(RabbitAccessor.java:113) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1462) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1412) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1388) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin.initialize(RabbitAdmin.java:500) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin$11.onCreate(RabbitAdmin.java:419) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.connection.CompositeConnectionListener.onCreate(CompositeConnectionListener.java:33) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:559) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1431) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1412) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:1388) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:336) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.redeclareElementsIfNecessary(SimpleMessageListenerContainer.java:1124) [spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1336) [spring-rabbit-1.6.10.RELEASE.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221]
Caused by: java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:105) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:101) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:123) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.exchangeDeclare(ChannelN.java:702) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.exchangeDeclare(ChannelN.java:60) ~[amqp-client-3.6.5.jar:?]
at org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl.exchangeDeclare(PublisherCallbackChannelImpl.java:293) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_221]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_221]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_221]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:929) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at com.sun.proxy.$Proxy145.exchangeDeclare(Unknown Source) ~[?:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin.declareExchanges(RabbitAdmin.java:554) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin.access$000(RabbitAdmin.java:66) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin$12.doInRabbit(RabbitAdmin.java:503) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1456) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
... 13 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'charge' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:32) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:360) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:225) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.exchangeDeclare(ChannelN.java:702) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.exchangeDeclare(ChannelN.java:60) ~[amqp-client-3.6.5.jar:?]
at org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl.exchangeDeclare(PublisherCallbackChannelImpl.java:293) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_221]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_221]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_221]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:929) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at com.sun.proxy.$Proxy145.exchangeDeclare(Unknown Source) ~[?:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin.declareExchanges(RabbitAdmin.java:554) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin.access$000(RabbitAdmin.java:66) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitAdmin$12.doInRabbit(RabbitAdmin.java:503) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:1456) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
... 13 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'charge' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10)
at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:483) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:320) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:143) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:90) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:559) ~[amqp-client-3.6.5.jar:?]
... 1 more
在当前报错堆栈的下一个报错信息是:
2020-01-06 11:16:46 [WARN ] o.s.a.r.l.BlockingQueueConsumer#attemptPassiveDeclarations:613 - Failed to declare queue:X55
2020-01-06 11:16:46 [WARN ] o.s.a.r.l.BlockingQueueConsumer#start:527 - Queue declaration failed; retries left=3
org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[X55]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:619) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:518) [spring-rabbit-1.6.10.RELEASE.jar:?]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1338) [spring-rabbit-1.6.10.RELEASE.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221]
Caused by: java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:105) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:101) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:123) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:884) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:60) ~[amqp-client-3.6.5.jar:?]
at org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl.queueDeclarePassive(PublisherCallbackChannelImpl.java:358) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_221]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_221]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_221]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:929) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at com.sun.proxy.$Proxy145.queueDeclarePassive(Unknown Source) ~[?:?]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:598) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
... 3 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=404, reply-text=NOT_FOUND - no queue 'X55' in vhost '/', class-id=50, method-id=10)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:32) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:360) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:225) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:884) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:60) ~[amqp-client-3.6.5.jar:?]
at org.springframework.amqp.rabbit.support.PublisherCallbackChannelImpl.queueDeclarePassive(PublisherCallbackChannelImpl.java:358) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_221]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_221]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_221]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory$CachedChannelInvocationHandler.invoke(CachingConnectionFactory.java:929) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
at com.sun.proxy.$Proxy145.queueDeclarePassive(Unknown Source) ~[?:?]
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:598) ~[spring-rabbit-1.6.10.RELEASE.jar:?]
... 3 more
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method(reply-code=404, reply-text=NOT_FOUND - no queue 'X55' in vhost '/', class-id=50, method-id=10)
at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:483) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:320) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:143) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:90) ~[amqp-client-3.6.5.jar:?]
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:559) ~[amqp-client-3.6.5.jar:?]
... 1 more
在上面报错堆栈中捕捉关键信息,
reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for exchange 'charge' in vhost '/': received 'true' but current is 'false', class-id=40, method-id=10
登陆rabbitmq的web端,通过网页新建exchange charge,新建完成之后,重启服务,仍然是相同的错误。
通过web页面再次查看rabbitmq的管理界面,发现我的exchange charge 的future上没有D标识,说明这个exchange不是持久化的,与消费端声明的队列有出入,果断删除这个exchange,重启服务进行尝试。
发现服务已经不报错,再看rabbitmq的web端管理界面,发现charge已经重新创建,并且是持久化的。问题解决。
水落石出
原来我这个问题的原因是由于项目中的excharge与rabbitmq中现存的exchange属性不一样,导致项目启动的时候报声明queue报错.