How to Purge an MSMQ Outgoing Queue

∥☆過路亽.° 提交于 2019-12-04 07:21:42

You should be able to purge it manually from the MMC snap-in. MSMQ gets very stingy when it reaches its storage limits, so a lot of operations will fail with "permission denied" and things like that.

The long-term solution obviously is to modify the configuration so there is enough storage space for your particular usage patterns.

Edit: You might be running into a limitation in the managed API related to admin capabilities and remote queues. Take a look at this article by Ingo Rammer. It even includes a p-invoke example.

it is possible use managed code to purge an outgoing queue:

using (var msgQueue = new MessageQueue(GetPrivateMqPath(queueName, remoteIP), QueueAccessMode.ReceiveAndAdmin))
{
    msgQueue.Purge();
}

in which GetPrivateMqPath is:

if (!string.IsNullOrEmpty(remoteIP))
    return String.Format("FORMATNAME:DIRECT=TCP:{0}\\private$\\{1}", remoteIP, queueName);
else
    return @".\private$\" + queueName;

QueueAccessMode.ReceiveAndAdmin points to outgoing queue.

You could try FORMATNAME:DIRECT=OS:computer\PRIVATE$\queuename.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!