Cannot determine whether a queue with the specified format name exists

前端 未结 5 1842
情歌与酒
情歌与酒 2021-02-04 04:28

I get the exception when executing the following code. Any ideas what is wrong?

string queueName = \"FormatName:Direct=TCP:1.1.1.1\\\\Private$\\\\test\";
Message         


        
5条回答
  •  迷失自我
    2021-02-04 05:16

    Try this...

      public static bool IsQueueAvailable(string queueName)
       {
            var queue = new MessageQueue(queueName);
            try
            {
                queue.Peek(new TimeSpan(0, 0, 5));
                return true;
            }
            catch (MessageQueueException ex)
            {
                return ex.Message.StartsWith("Timeout");
            }
        }
    

    If the queue doesn't exist or if the account running the app doesn't have sufficient rights to get to it, the exception message clearly states so.

    AND, this would work with both FormatName and the usual queue path.

提交回复
热议问题