身份验证失败 spring-amqp 超时

Authentication failure spring-amqp timeout

我的消费者工作了大约一个星期,然后消费者线程死了并记录了以下错误:

It seems the Authentication failure is caused by BufferedInputStream.read timeout, and I want to know if there is a way to treat the Authentication failure as a non-fatal and do not kill the consumer thread. and I think the timeout issue is just caused by network issue not the Authentication failure, since this consumer already worked for one week.

org.springframework.amqp.rabbit.listener.exception.FatalListenerStartupException: Authentication failure
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:460)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1171)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.PossibleAuthenticationFailureException: Possibly caused by authentication failure
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:61)
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:296)
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:524)
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:85)
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:135)
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:71)
at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:456)
... 2 more
Caused by: com.rabbitmq.client.PossibleAuthenticationFailureException: Possibly caused by authentication failure
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:341)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:824)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:736)
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:283)
... 7 more
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error at com.rabbitmq.utility.ValueOrException.getValue(ValueOrExcept‌​ion.java:66) at com.rabbitmq.utility.BlockingValueOrException.uninterruptibl‌​eGetValue(BlockingVa‌​lueOrException.java:‌​36) at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.‌​getReply(AMQChannel.‌​java:366) at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.ja‌​va:233) at com.rabbitmq.client.impl.AMQChannel.rpc(AMQChannel.java:211) at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.j‌​ava:326) 

目标代码如下:

} catch (ShutdownSignalException e) {
...
   throw new PossibleAuthenticationFailureException(e);
}

因此,确实,连接问题不一定与身份验证有关。

Connection timed out原因只有ShutdownSignalException

因此,您应该尝试增加连接超时,默认情况下为 60000

但这可能是代理上的资源有问题,因为我们无法连接。

我们不能将此类错误 (ShutdownSignalException) 视为非致命错误,因为您的问题正好发生在 start().

编辑

如果发生致命故障,容器会发出 ListenerContainerConsumerFailedEvent:http://docs.spring.io/spring-amqp/reference/html/_reference.html#consumer-events。你可以处理它并故意重新启动容器。