社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  MQ

RabbitHandler在Spring中创建使用者并在侦听rabbitmq时重试队列的致命异常

sunder • 6 年前 • 3150 次点击  

我正在使用Spring AMQP RabbitHandler,并编写了以下代码:-

@RabbitListener(queues = "#{testQueue.name}")
public class Tut4Receiver {

  @RabbitHandler
  public void receiveMessage(String message){
       System.out.println("Message received "+message);
  }
}

队列的定义如下:-

@Bean
public Queue testQueue() {
    return new AnonymousQueue();
}

我正在使用单独的代码初始化连接工厂。

我的问题是,如果rabbitmq关闭了一段时间,它会继续尝试创建一个消费者,但前提是它收到一个connectionrejected错误。但是假设用户不存在于RabBMQ中,并且有一个新用户将被创建的间隙,那么它从RabByMQ接收到致命错误,并且它不会重试,因为在没有任何消费者的情况下,将在兔子MQ上创建结果是自动删除队列。

堆栈跟踪:-

    SimpleMessageListenerContainer] [SimpleAsyncTaskExecutor-11] [|] [|||] Consumer received fatal exception on startup 
org.springframework.amqp.rabbit.listener.exception.FatalListenerStartupException: Authentication failure
    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:476)
    at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1280)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.amqp.AmqpAuthenticationException: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using     authentication mechanism PLAIN. For details see the broker logfile.
    at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:65)
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:309)
    at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:547)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils$1.createConnection(ConnectionFactoryUtils.java:90)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.doGetTransactionalResourceHolder(ConnectionFactoryUtils.java:140)
    at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.getTransactionalResourceHolder(ConnectionFactoryUtils.java:76)
    at org.springframework.amqp.rabbit.listener.BlockingQueueConsumer.start(BlockingQueueConsumer.java:472)
    ... 2 common frames omitted
Caused by: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details see the broker     logfile.
    at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:339)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:813)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:767)
    at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:887)
    at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:300)

 SimpleMessageListenerContainer] [SimpleAsyncTaskExecutor-11] [|] [|||] Stopping container from aborted consumer 
  [|] [|||] Waiting for workers to finish. 
  [|] [|||] Successfully waited for workers to finish. 

即使在像用户一样致命异常的情况下,也不存在重试的方法吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49292
文章 [ 1 ]  |  最新文章 6 年前