I try this: MessageQueue mq = new MessageQueue(".\Journal$"); mq.Purge();
It work good on XP. But, on windows 2003 server, I always have this error : "A workgroup installation computer does not support the operation."
I try this: MessageQueue mq = new MessageQueue(".\Journal$"); mq.Purge();
It work good on XP. But, on windows 2003 server, I always have this error : "A workgroup installation computer does not support the operation."
Try using format name like so:
MessageQueue mq = new MessageQueue("DIRECT=OS:computername\SYSTEM$;JOURNAL");
mq.Purge();
I think that system queue can't be access by path. You have to use format name.
The correct format for system queues:
FormatName:Direct=os:.\\System$;JOURNAL
I've tested this format on Windows 7 and Windows 2003.
(the dot after os: means the localhost/local computer)
var systemJournalQueue = new MessageQueue("FormatName:Direct=os:.\\System$;JOURNAL");
var systemDeadLetterQueue = new MessageQueue("FormatName:Direct=os:.\\System$;DEADLETTER");
var systemDeadXLetterQueue =new MessageQueue("FormatName:Direct=os:.\\System$;DEADXACT"));
systemJournalQueue.Purge();
or if you want to keep N days of messages you can do this:
private static void PurgeQueues(int archiveAfterHowManyDays, MessageQueue queue)
{
queue.Formatter = new XmlMessageFormatter(new Type[] { typeof(System.String) });
queue.MessageReadPropertyFilter.ArrivedTime = true;
using (MessageEnumerator messageReader = queue.GetMessageEnumerator2())
{
while (messageReader.MoveNext())
{
Message m = messageReader.Current;
if (m.ArrivedTime.AddDays(archiveAfterHowManyDays) < DateTime.Now)
{
queue.ReceiveById(m.Id);
}
}
}
}
Try using format name like so:
MessageQueue mq = new MessageQueue("DIRECT=OS:computername\SYSTEM$;JOURNAL");
mq.Purge();
I think that system queue can't be access by path. You have to use format name.
© 2022 - 2024 — McMap. All rights reserved.