How to Purge an MSMQ Outgoing Queue
Asked Answered
H

3

6

Is there any way to purge an outgoing queue. It doesn't appear that I can do it with the MMC snap-in and when i try to purge it in code i get an error Format name is invalid the computer it's sending the messages to does not exist, so they will never be sent, however the queues filled up the max storage space for MSMQ so everytime my application tries to send another message i get the insufficient resources exception.

I've tried the following formats and they all fail with the exception format name is invalid

DIRECT=OS:COMPUTER\private$\queuename
OS:COMPUTER\private$\queuename
COMPUTER\private$\queuename

Honeywell answered 26/1, 2011 at 17:27 Comment(1)
It's the queue that sent messages get saved in before they're sent to another computer.Honeywell
M
6

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.

Malachi answered 26/1, 2011 at 17:58 Comment(1)
Nice article, didn't get to try it out though. Because one of the images on the screen showed me what i was doing wrong lol. I was right clicking the queue name and excepting the purge option to show up there. Had to go deeper and right click "Queue Messages"Honeywell
H
3

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.

Hubbell answered 26/9, 2012 at 20:10 Comment(0)
G
1

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

Glabella answered 26/1, 2011 at 17:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.