zoukankan      html  css  js  c++  java
  • Rabbitmq消息服务器通讯异常: name must not be blank

    前人挖坑,后人填! 倒霉的遇到一个破项目,该 项目使用了 RabbitMQ 消息队列向服务器发送消息, 但在发送中老是报 RabbitMQ 服务器异常! 呃,查看了服务器,服务器好好的,日志中却是这样的记录, 真是见鬼, 调试跟踪了一下发现:

    RabbitMQ消息服务器通讯异常:System.ArgumentException: name must not be blank
    参数名: name
    在 EasyNetQ.Preconditions.CheckNotBlank(String value, String name, String message)
    在 EasyNetQ.RabbitAdvancedBus.QueueDeclare(String name, Boolean passive, Boolean durable, Boolean exclusive, Boolean autoDelete, Nullable`1 perQueueMessageTtl, Nullable`1 expires, Nullable`1 maxPriority, String deadLetterExchange, String deadLetterRoutingKey, Nullable`1 maxLength, Nullable`1 maxLengthBytes)
    在 EasyNetQ.Producer.SendReceive.<>c__DisplayClass12_0.<DeclareQueue>b__0(String key)
    在 System.Collections.Concurrent.ConcurrentDictionary`2.AddOrUpdate(TKey key, Func`2 addValueFactory, Func`3 updateValueFactory)
    在 EasyNetQ.Producer.SendReceive.DeclareQueue(String queueName)
    在 EasyNetQ.Producer.SendReceive.Send[T](String queue, T message)

    这个异常主要 是在调用  RabbitMQ接口的Send 方法时,抛出来的,先来看看 Send 方法的说明 

            //
            // Summary:
            //     Send a message directly to a queue
            //
            // Parameters:
            //   queue:
            //     The queue to send to
            //
            //   message:
            //     The message
            //
            // Type parameters:
            //   T:
            //     The type of message to send
            void Send<T>(string queue, T message) where T : class;

     这个接口中有两个参数, queue和 message , 但这现个参数 queue 是不能为空的,它表示的是一个队列的名称

    解决方案: 

     在向 Send 接口传递queue 参数时,判断下是否为空或null

  • 相关阅读:
    gdb调试libtool封装的可执行文件
    转载 Linux top命令详解
    VirtualBox使用物理硬盘建立磁盘
    【sqlServer】常用语句整理
    【c#基础】特殊集合
    【c# 基础】各种集合的不同情况下的性能
    【c#集合】Lookup 类 有序字典 SortedDictionary<TKey,TValue> 集
    【c#基础】集合--栈Stack 链表 LinkList 有序列表SortedList 字典Dictionary
    【c#基础】集合
    【c#基础】委托、Lambda表达式和事件
  • 原文地址:https://www.cnblogs.com/wisdo/p/10737768.html
Copyright © 2011-2022 走看看