文章目录

    • 一.运行时报错
    • 二.解决方法


rabbitmq多个微服务可用,因此我将其抽离到common模块。并重写封装了该方法。使用了
spring-boot-starter-amqp启动器。每个微服务都可以做生产者和消费者,符合业务需求。
参考: https://www.cnblogs.com/xudong5273/p/16499538.html

一.运行时报错

Channel shutdown: channel error; protocol method: #method channel.close (reply-code=404, reply-text=


二.解决方法

通用配置

  #配置RabbitMQ
  rabbitmq:
    host: localhost
    port: 5672
    username: 123
    password: 123
    publisher-confirm-type: correlated # NONE值是禁用发布确认模式,是默认值 CORRELATED值是开启发布确认模式 SETTINGS值是开启发布确认模式
    publisher-returns: true # 开启消息发送失败返回功能
    template:
      mandatory: true # 设置为 true 后 消费者在消息没有被路由到合适队列情况下会被return监听,而不会自动删除
    listener: # 消费者监听器配置
      simple:
        acknowledge-mode: manual # 消费者手动确认模式
#        auto-startup: false
      direct:
        acknowledge-mode: manual # 消费者手动确认模式
#        auto-startup: false

大致场景是启动springboot时报错;原因是:当应用启动时,spring 会去检查注册的队列,跟服务器上的队列配置是否一致,如果不一致,则抛出这个错误
在这里插入图片描述

更多推荐