前人挖坑,后人填! 倒霉的遇到一个破项目,该 项目使用了 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

 

posted on 2019-04-30 18:50  wisdo  阅读(2231)  评论(0编辑  收藏  举报