队列持久化异常"/>
com.rabbitmq.client.ShutdownSignalException,RabbitMQ队列持久化异常
一、问题描述
RabbitMQ创建队列之后,如果需要改为持久化的队列,如果一开始没有指定或者指定durable属性为false,默认不持久化队列,当使用如下代码
package com.atguigu.rabbitmq.three;import com.atguigu.rabbitmq.util.RabbitMQUtil;
import com.rabbitmq.client.Channel;import java.util.Scanner;/*** @author kiki* @date 2022/6/30* @description 消息在手动应答时是不丢失、放回队列中重新进行消费*/
public class task2 {public static final String TASK_QUEUE_NAME = "ack_queue";public static void main(String[] args) throws Exception {Channel channel = RabbitMQUtil.getChannel();boolean durable = true;//声明队列channel.queueDeclare(TASK_QUEUE_NAME,durable,false,false,null);//从控制台输入信息Scanner scanner = new Scanner(System.in);while (scanner.hasNext()){String message = scanner.next();channel.basicPublish("",TASK_QUEUE_NAME,null,message.getBytes("UTF-8"));System.out.println("生产者发出消息:"+message);}}}
指定队列持久化,此时会报
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'ack_queue' in vhost '/': received 'true' but current is 'false', class-id=50, method-id=10)
此时需要去客户端RabbitMQ
去删除队列,然后重新创建才可。
更多推荐
com.rabbitmq.client.ShutdownSignalException,RabbitMQ队列持久化异常
发布评论