RabbitMQ客户端关闭了MessageListener,无法恢复。

huangapple go评论86阅读模式
英文:

RabbitMQ Client shuts down the MessageListener and cannot be recovered

问题

I use RabbitMQ AMQP 2.2.7. I have the RabbitMQ cluster running between 2 Spring boot application. One application posts some messages to the other one. It was running well for sometime but suddenly for the last few days, i see that MessageListener in the application that consumes the message goes down for some reason (May be the master server node went down).

   <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit</artifactId>
            <version>2.2.7.RELEASE</version>
   </dependency>

2020-07-22 00:26:33.007 ERROR 24 --- [tContainer#1-15] o.s.a.r.l.SimpleMessageListenerContainer : Stopping container from aborted consumer
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - home node 'rabbit@rad497159-mq-1.node.dc1.a9ssvc' of durable queue 'ORDER' in vhost '/' is down or inaccessible, class-id=50, method-id=10)
Caused by: java.io.IOException: null
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
2020-07-22 00:26:33.005 ERROR 24 --- [tContainer#1-15] o.s.a.r.l.SimpleMessageListenerContainer : Consumer threw missing queues exception, fatal=true
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1350) ~[spring-rabbit-2.2.7.RELEASE.jar:2.2.7.RELEASE]

@Configuration
public class MessageConfiguration {

    public static final String ORDER_QUEUE_NAME = &quot;ORDER&quot;;

    public static final String EXCHANGE = &quot;directExchange&quot;;

    @Bean
    Queue deadLetterQueue() {
        return QueueBuilder.durable(ORDER_QUEUE_NAME).build();
    }

    @Bean
    public Queue orderQueue(){
        return QueueBuilder.durable(ORDER_QUEUE_NAME)
                .build();
    }

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange(EXCHANGE,true,false);
    }

    @Bean
    public Binding firstBinding(Queue orderQueue, DirectExchange directExchange){
        return BindingBuilder.bind(orderQueue).to(directExchange).with(ORDER_QUEUE_NAME);
    }
}
@RabbitListener(queues = MessageConfiguration.ORDER_QUEUE_NAME)
public void receiveOrder(final String orderString) {
}

The problem is RabbitMQ message listener shuts down indefinitely and there is no other way to recover. Restarting the application solves the problem. So I would like have one of the following solutions but don't know how to do that:

  1. Listen for the shutdown notification from SimpleMessageListener and restart the application.
  2. Make the application retry more times before shutting down the listener.

Could someone please suggest some way?

There is already the same issue in stackoverflow without solution (https://stackoverflow.com/questions/42501328/how-to-avoid-shutdown-of-simplemessagelistenercontainer-in-case-of-unexpected-er)

英文:

I use RabbitMQ AMQP 2.2.7. I have the RabbitMQ cluster running between 2 Spring boot application. One application posts some messages to the other one. It was running well for sometime but suddenly for the last few days, i see that MessageListener in the application that consumes the message goes down for some reason (May be the master server node went down).

   &lt;dependency&gt;
            &lt;groupId&gt;org.springframework.amqp&lt;/groupId&gt;
            &lt;artifactId&gt;spring-rabbit&lt;/artifactId&gt;
            &lt;version&gt;2.2.7.RELEASE&lt;/version&gt;
   &lt;/dependency&gt;
2020-07-22 00:26:33.007 ERROR 24 --- [tContainer#1-15] o.s.a.r.l.SimpleMessageListenerContainer : Stopping container from aborted consumer
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method&lt;channel.close&gt;(reply-code=404, reply-text=NOT_FOUND - home node &#39;rabbit@rad497159-mq-1.node.dc1.a9ssvc&#39; of durable queue &#39;ORDER&#39; in vhost &#39;/&#39; is down or inaccessible, class-id=50, method-id=10)
Caused by: java.io.IOException: null
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
2020-07-22 00:26:33.005 ERROR 24 --- [tContainer#1-15] o.s.a.r.l.SimpleMessageListenerContainer : Consumer threw missing queues exception, fatal=true
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1350) ~[spring-rabbit-2.2.7.RELEASE.jar:2.2.7.RELEASE]
@Configuration
public class MessageConfiguration {

	public static final String ORDER_QUEUE_NAME = &quot;ORDER&quot;;

	public static final String EXCHANGE = &quot;directExchange&quot;;

	@Bean
	Queue deadLetterQueue() {
		return QueueBuilder.durable(ORDER_QUEUE_NAME).build();
	}

	@Bean
	public Queue orderQueue(){
		return QueueBuilder.durable(ORDER_QUEUE_NAME)
				.build();
	}

	@Bean
	public DirectExchange directExchange(){
		return new DirectExchange(EXCHANGE,true,false);
	}

	@Bean
	public Binding firstBinding(Queue orderQueue, DirectExchange directExchange){
		return BindingBuilder.bind(orderQueue).to(directExchange).with(ORDER_QUEUE_NAME);
	}
}

@RabbitListener(queues = MessageConfiguration.ORDER_QUEUE_NAME)
public void receiveOrder(final String orderString) {
}

The problem is RabbitMQ message listener shuts down indefinitley and there is no other way to recover. Restarting the application solves the problem. So i would like have one of the following solution but dont know how to do that

  1. Listen for the shutdown notification from SimpleMessageListener and restart the application
  2. Make the application retry more times before shutting down the listener

Could someone please suggest some way ?

There is already the same issue in stackoverflow without solution (https://stackoverflow.com/questions/42501328/how-to-avoid-shutdown-of-simplemessagelistenercontainer-in-case-of-unexpected-er)

答案1

得分: 6

home node 'rabbit@rad497159-mq-1.node.dc1.a9ssvc' of durable queue 'ORDER' in vhost '/' is down or inaccessible, class-id=50, method-id=10):

"持久队列 'ORDER' 在虚拟主机 '/' 中的主节点 'rabbit@rad497159-mq-1.node.dc1.a9ssvc' 已关闭或无法访问,class-id=50,method-id=10。"

It looks like you are using a cluster but without using a mirrored (HA) queue.

"看起来您正在使用集群,但没有使用镜像(高可用)队列。"

In that case, if the queue's home node goes down, you will get that error.

在这种情况下,如果队列的主节点关闭,您将收到此错误。

Consumer threw missing queues exception, fatal=true:

"消费者引发了缺少队列异常,fatal=true。"

If you set the container property missingQueuesFatal to false, the container will keep trying until the node is back up.

如果将容器属性 missingQueuesFatal 设置为 false,容器将不断尝试,直到节点恢复正常。

By default, this is true and the container will stop after 3 attempts 5 seconds apart (by default).

默认情况下,这是 true,并且容器将在默认情况下的 3 次尝试之后停止,每次间隔 5 秒。

英文:

>home node &#39;rabbit@rad497159-mq-1.node.dc1.a9ssvc&#39; of durable queue &#39;ORDER&#39; in vhost &#39;/&#39; is down or inaccessible, class-id=50, method-id=10)

It looks like you are using a cluster but without using a mirrored (HA) queue.

In that case, if the queue's home node goes down, you will get that error.

>Consumer threw missing queues exception, fatal=true

If you set the container property missingQueuesFatal to false, the container will keep trying until the node is back up.

By default, this is true and the container will stop after 3 attempts 5 seconds apart (by default).

huangapple
  • 本文由 发表于 2020年7月22日 22:21:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/63036460.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定