com.rabbitmq.client.ShutdownSignalException,RabbitMQ队列持久化异常

编程入门 行业动态 更新时间:2024-10-08 06:27:03

com.rabbitmq.client.ShutdownSignalException,RabbitMQ<a href=https://www.elefans.com/category/jswz/34/1771257.html style=队列持久化异常"/>

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队列持久化异常

本文发布于:2024-02-14 12:47:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1763215.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:队列   持久   异常   client   rabbitmq

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!