programmatically add private queues in MSMQ

irvinedotnet picture irvinedotnet · Apr 6, 2011 · Viewed 9.8k times · Source

I have list of over 20 queues that needs to be added as private queue in MSMQ.

Is there a way to do it using

  1. Command Line

  2. C# programming

If there is a way to do using some sort of script or .net programming then I could add it with out manually inputting it and causing typos.

Please let me know.

thanks

Answer

Richard Schneider picture Richard Schneider · Apr 6, 2011
using System.Messaging;

//...

void CreateQueue(string qname) {
   if (!MessageQueue.Exists(qname)) MessageQueue.Create(qname);
}

You can only create private queues on your local computer. For more information see: Creating Queues