Search code examples
c#.netwindowsmsmq

How does MS Windows purge MSMQ


I have multiple instances of the same app working with MSMQ.

So I use code like this

MessageQueue.Create(@".\Private$\MyApp" + Process.GetCurrentProcess().Id);

But each time app starts it is gonna create new MSMQ.

Will MS Windows keep old MSMQ for ever or they will be deleted automatically?


Solution

  • Once you create the queue it remains on that system. They are never automatically deleted. If you're just creating it for temporary or testing purposes and you need to remove it you can call

    MessageQueue.Delete([your queue path]);
    

    Sometimes I've done that when unit testing.