ERROR 24392 --- o.s.a.r.c.CachingConnectionFactory : Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=404, reply-text=NOT_FOUND - no exchange 'trade.topic' in vhost '/hmall', class-id=60, method-id=40)

或 Failed to check/redeclare auto-delete queue(s).

分析:报错原因就是找不到自己配置的交换机。

1--如果你确保定义交换机和使用时没写错字母:

//定义交换机绑定队列   
 @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "cart.clear.queue", durable = "true"),
            exchange = @Exchange(name = "trade.topic", type = "topic"),
            key = "order.create"
    ))









//在别的服务中使用
 rabbitTemplate.convertAndSend("trade.topic","order.create",createOrderMesDTO);

2--八九成就是配置出问题了,检查yaml文件rabbitmq的配置,确保正确配置如下信息。如果使用默认的虚拟主机virtual-host选项就不需要配置

spring:
  rabbitmq:
    host:  # 你的虚拟机IP
    port: 5672 # 端口
    virtual-host:  # 虚拟主机名
    username:  # 用户名
    password:  # 密码

3--如果使用的是nacos管理配置,要确保正确拉取到了rabbitmq的配置

更多推荐