RabbitMQ报错 received ‘topic‘ but current is ‘direct‘

控制台报错提示:

Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'topic' in vhost '/': received 'topic' but current is 'direct', class-id=40, method-id=10)

翻译过来就是 收到'topic',但当前是'direct

解决办法:

错误代码 : 

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue("tiopic.queueq1"),
            exchange = @Exchange(value = "topic", type = ExchangeTypes.TOPIC),
            key = "www.#"
    ))
    public void listenTopicQueue1(String msg){
        System.out.println("消费者接收到topic.queue1的消息:【" + msg + "】");
    }

正确代码: 重新换一个交换机的名称就好了

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "tiopic.queue2"),
            exchange = @Exchange(name = "topic1", type = ExchangeTypes.TOPIC),
            key = "#.baidu"
    ))
    public void listenTopicQueue2(String msg){
        System.out.println("消费者接收到topic.queue1的消息:【" + msg + "】");
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Max恒

为了开源加油 ! !

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值