簡體   English   中英

Spring Bus Rabbit Amqp客戶端長時間斷開空閑連接

[英]Spring bus rabbit amqp client drops connection on idle for long time

**Versions**
RabbitMQ 3.6.14. (using docker image rabbitmq:3.6.14-management-alpine)

Java 1.8

spring-cloud-starter-bus-amqp => 1.3.1.RELEASE


 Spring boot parent => 1.5.9.RELEASE

我使用amqp mvn框架通過spring boot服務設置了rabbitmq,以便可以遠程刷新配置。 最初一切正常,但隨后連接斷開。

下面的錯誤堆棧還鏈接: https : //docs.google.com/document/d/1Hk3DnA7dMIMevjvoew2Shy5OQsShizrPKRys_U2lghM/edit?usp=sharing

2018-05-22 17:10:49.647 ERROR 9 --- [.X.X.228:5671] c.r.c.impl.ForgivingExceptionHandler     : An unexpected connection driver error occured

com.rabbitmq.client.MissedHeartbeatException: Heartbeat missing with heartbeat = 10 seconds     at com.rabbitmq.client.impl.AMQConnection.handleSocketTimeout(AMQConnection.java:723)   at com.rabbitmq.client.impl.AMQConnection.readFrame(AMQConnection.java:642)     at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:47)     at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:572)  at java.lang.Thread.run(Thread.java:745)

2018-05-22 17:10:49.652 ERROR 9 --- [.X.X.228:5671] o.s.a.r.c.CachingConnectionFactory       : Channel shutdown: connection error 2018-05-22 17:10:49.652 ERROR 9 --- [.X.X.228:5671] o.s.a.r.c.CachingConnectionFactory       : Channel shutdown: connection error 2018-05-22 17:10:50.581  INFO 9 --- [NiW8BAjOWTiVA-1] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer@574b7f4a: tags=[{amq.ctag-m35NYazOB0vmhjJHwayDMg=springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA}], channel=Cached Rabbit Channel: AMQChannel(amqp://admin@10.X.X.228:5671/,1), conn: Proxy@76ad6715 Shared Rabbit Connection: SimpleConnection@5a1c3cb4 [delegate=amqp://admin@10.X.X.228:5671/, localPort= 43472], acknowledgeMode=AUTO local queue size=0 2018-05-22 17:10:50.609  INFO 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.c.CachingConnectionFactory       : Created new connection: rabbitConnectionFactory#934b52f:1/SimpleConnection@3cd111c6 [delegate=amqp://admin@10.X.X.78:5671/, localPort= 50792] 2018-05-22 17:10:50.613  INFO 9 --- [NiW8BAjOWTiVA-2] o.s.amqp.rabbit.core.RabbitAdmin         : Auto-declaring a non-durable, auto-delete, or exclusive Queue (springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost. 2018-05-22 17:10:50.617 ERROR 9 --- [0.X.X.78:5671] o.s.a.r.c.CachingConnectionFactory       : Channel shutdown: channel error; protocol method:
#method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=10) 2018-05-22 17:10:50.619  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.amqp.rabbit.core.RabbitAdmin         : Failed to declare queue: Queue [name=springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA, durable=false, autoDelete=true, exclusive=true, arguments={}], continuing... com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=10) 2018-05-22 17:10:50.621 ERROR 9 --- [0.X.X.78:5671] o.s.a.r.c.CachingConnectionFactory       : Channel shutdown: channel error; protocol method:
#method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=20) 2018-05-22 17:10:50.623  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.amqp.rabbit.core.RabbitAdmin         : Failed to declare binding: Binding [destination=springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA, exchange=springCloudBus, routingKey=#], continuing... com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=20) 2018-05-22 17:10:50.629 ERROR 9 --- [0.X.X.78:5671] o.s.a.r.c.CachingConnectionFactory       : Channel shutdown: channel error; protocol method:
#method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=10) 2018-05-22 17:10:50.630  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.listener.BlockingQueueConsumer   : Failed to declare queue: springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA 2018-05-22 17:10:50.631  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.listener.BlockingQueueConsumer   : Queue declaration failed; retries left=3

org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA]   at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:672)    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:571)     at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1424)     at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: null   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:992)     at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:50)  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:980)     at com.sun.proxy.$Proxy155.queueDeclarePassive(Unknown Source)  at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:651)    ... 3 common frames omitted Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' 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:366)    at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229)  at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117)  ... 12 common frames omitted Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=10)  at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:505)   at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:336)    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.readFrame(AMQConnection.java:634)     at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:47)     at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:572)  ... 1 common frames omitted

2018-05-22 17:10:55.635  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.listener.BlockingQueueConsumer   : Failed to declare queue: springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA 2018-05-22 17:10:55.636  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.listener.BlockingQueueConsumer   : Queue declaration failed; retries left=2

org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA]   at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:672)    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:571)     at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1424)     at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: null   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:992)     at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:50)  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:980)     at com.sun.proxy.$Proxy155.queueDeclarePassive(Unknown Source)  at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:651)    ... 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 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' 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:366)    at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229)  at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117)  ... 12 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 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=10)  at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:505)   at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:336)    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.readFrame(AMQConnection.java:634)     at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:47)     at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:572)  ... 1 common frames omitted

2018-05-22 17:11:00.656  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.listener.BlockingQueueConsumer   : Failed to declare queue: springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA 2018-05-22 17:11:00.657  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.listener.BlockingQueueConsumer   : Queue declaration failed; retries left=1

org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA]   at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:672)    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:571)     at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1424)     at java.lang.Thread.run(Thread.java:745) Caused by: java.io.IOException: null   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:992)     at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:50)  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:980)     at com.sun.proxy.$Proxy155.queueDeclarePassive(Unknown Source)  at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:651)    ... 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 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' 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:366)    at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229)  at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117)  ... 12 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 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=10)  at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:505)   at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:336)    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.readFrame(AMQConnection.java:634)     at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:47)     at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:572)  ... 1 common frames omitted

2018-05-22 17:11:05.662  WARN 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.listener.BlockingQueueConsumer   : Failed to declare queue: springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA 2018-05-22 17:11:05.664 ERROR 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.l.SimpleMessageListenerContainer : Consumer received fatal=false exception on startup

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:599)     at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1424)     at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA]   at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:672)    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:571)     ... 2 common frames omitted Caused by: java.io.IOException: null    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:992)     at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:50)  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:980)     at com.sun.proxy.$Proxy155.queueDeclarePassive(Unknown Source)  at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:651)    ... 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 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' 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:366)    at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229)  at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117)  ... 12 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 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=10)  at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:505)   at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:336)    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.readFrame(AMQConnection.java:634)     at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:47)     at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:572)  ... 1 common frames omitted

2018-05-22 17:11:05.664 ERROR 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.l.SimpleMessageListenerContainer : Consumer received fatal exception on startup

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:599)     at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1424)     at java.lang.Thread.run(Thread.java:745) Caused by: org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationException: Failed to declare queue(s):[springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA]   at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:672)    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:571)     ... 2 common frames omitted Caused by: java.io.IOException: null    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:992)     at com.rabbitmq.client.impl.ChannelN.queueDeclarePassive(ChannelN.java:50)  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:980)     at com.sun.proxy.$Proxy155.queueDeclarePassive(Unknown Source)  at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.attemptPassiveDeclarations(BlockingQueueConsumer.java:651)    ... 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 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' 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:366)    at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:229)  at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:117)  ... 12 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 'springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA' in vhost '/', class-id=50, method-id=10)  at com.rabbitmq.client.impl.ChannelN.asyncShutdown(ChannelN.java:505)   at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:336)    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.readFrame(AMQConnection.java:634)     at com.rabbitmq.client.impl.AMQConnection.access$300(AMQConnection.java:47)     at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:572)  ... 1 common frames omitted

2018-05-22 17:11:05.666 ERROR 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.l.SimpleMessageListenerContainer : Stopping container from aborted consumer 2018-05-22 17:11:05.666  INFO 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.l.SimpleMessageListenerContainer : Waiting for workers to finish. 2018-05-22 17:11:05.666  INFO 9 --- [NiW8BAjOWTiVA-2] o.s.a.r.l.SimpleMessageListenerContainer : Successfully waited for workers to finish.

知道為什么空閑連接斷開。 心跳設置為10秒。 Rabbitmq已啟用ssl。

osamqp.rabbit.core.RabbitAdmin:自動聲明一個

不可持久,自動刪除或專用隊列

(springCloudBus.anonymous.eV7zCVLlSNiW8BAjOWTiVA)持久性:false,

自動刪除:true,排除:true。 如果經紀人將重新宣布

連接工廠處於活動狀態時停止並重新啟動,但是所有

消息將丟失。 2018-05-22 17:10:50.617錯誤9-

[0.XX78:5671] osarcCachingConnectionFactory:通道

關閉:通道錯誤; 協議方法:

方法(回復代碼= 405,回復文本= RESOURCE_LOCKED-無法獲得對鎖定隊列的獨占訪問

似乎存在競爭狀況-Rabbit Admin無法重新聲明匿名,自動刪除,互斥隊列,因為舊隊列仍然臨時存在。

隨后,該容器嘗試執行被動聲明,並且到那時隊列還不存在。

我認為我們需要為RabbitAdmin添加一些重試功能。 我已打開JIRA問題

編輯

這有點粗糙,但是可以解決...

@Bean
public static Object addDelayOnReconnect(CachingConnectionFactory connectionFactory) {
    connectionFactory.addConnectionListener(new ConnectionListener() {

        private final AtomicBoolean initialConnection = new AtomicBoolean(true);

        @Override
        public void onCreate(Connection connection) {
            if (!this.initialConnection.compareAndSet(true, false)) {
                try {
                    System.out.println("Waiting a while for auto-delete queues to be deleted...");
                    Thread.sleep(5_000);
                    System.out.println("Continuing...");
                }
                catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                }
            }
        }

        @Override
        public void onClose(Connection connection) {
            // empty
        }
    });
    return new Object();
}

2018-05-22 17:16:45.599  ... : Created new connection: rabbitConnectionFactory#787e4357:1/SimpleConnection@37c0e81b [delegate=amqp://guest@127.0.0.1:5672/, localPort= 50201]
Waiting a while for auto-delete queues to be deleted...
Continuing...
2018-05-22 17:16:50.605 ... : Auto-declaring a non-durable, auto-delete, or exclusive Queue (springCloudBus.anonymous.RQp18TX0SpObVqJSEr64hQ) durable:false, auto-delete:true, exclusive:true. It will be redeclared if the broker stops and is restarted while the connection factory is alive, but all messages will be lost.

注意,我將其設置為static bean是因為我們希望將此偵聽器添加到RabbitAdmin之前; 它對我有用,沒有static但YMMV。 如果發現首先添加了admin,則可以使用setConnectionListeners恢復為替換偵聽器列表-但請確保將RabbitAdmin添加到列表中,以便它將執行聲明。

您可以通過循環調用RabbitAdmin.getQueueProperties()使其變得更加復雜,直到不再存在隊列為止(盡管查找隊列名稱可能並不容易)。

EDIT2

這是一個更好的解決方法-覆蓋Boot的AmqpAdmin bean ...

@Bean
public AmqpAdmin amqpAdmin(ConnectionFactory connectionFactory) {
    return new RabbitAdmin(connectionFactory) {

        @Override
        public void initialize() {
            while (true) { // might want to give up after some number of tries
                try {
                    super.initialize();
                    break;
                }
                catch (Exception e) {
                    System.out.println("Failed to declare elements: " + e.getCause().getCause().getMessage());
                    try {
                        Thread.sleep(1_000);
                    }
                    catch (InterruptedException e1) {
                        Thread.currentThread().interrupt();
                    }
                }
            }
        }

    };
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM