zoukankan      html  css  js  c++  java
  • rabbitmq 学习错误总结

    1,bind时候出错
            // 定义一个queue,durable(即rabbitmq重启后也不会消失)
            DeclareOk queueDeclare = channel.queueDeclare("test.queue", true)
            channel.exchangeDeclare( "test.exchange", "direct");
            channel.queueBind("test.queue", "test.exchange", "test.routingkey");
            //上面如果定义一个 durability 的queue,就会出现异常
    java.io.IOException
        at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:121)
        at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:139)
        at com.rabbitmq.client.impl.ChannelN.queueBind(ChannelN.java:502)
        at com.rabbitmq.client.impl.ChannelN.queueBind(ChannelN.java:512)
        at com.rabbitmq.client.impl.ChannelN.queueBind(ChannelN.java:70)
        at TestSender.sendMsg(TestSender.java:67)
        at TestSender.main(TestSender.java:85)
    Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; reason: {#method<connection.close>(reply-code=530,reply-text=NOT_ALLOWED - durability settings of queue 'test.queue' in vhost '/' incompatible with exchange 'test.exchange' in vhost '/',class-id=50,method-id=20),null,""}
        at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:81)
        at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:47)
        at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:336)
        at com.rabbitmq.client.impl.AMQChannel.rpc(AMQChannel.java:209)
        at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:133)
        ... 5 more
    根据提示,找到了原因,如果定义一durable的queue,那么bind此queue的exchange也必须是durable的,解决办法
    1,channel.queueDeclare(queue, true);  channel.exchangeDeclare(exchange, "direct", true);
    2,channel.queueDeclare(queue);  channel.exchangeDeclare(exchange, "direct");
  • 相关阅读:
    用于json的 .ashx 小细节
    (转)写让别人能读懂的代码
    Mvc 中ViewBag Model 查找不到解决
    Windows 2008 R2 配置 DNS 实现二级域名
    Windows Server 2008 DNS服务器安装与配置
    【iOS】swift init构造器
    【iOS】OC-UTC日期字符串格式化
    android使用sharesdk的小感
    【iOS】Swift GCD-下
    【iOS】Swift GCD-上
  • 原文地址:https://www.cnblogs.com/amityat/p/2160052.html
Copyright © 2011-2022 走看看