This documentation is archived and is not being maintained.

Creating Queues

You create a queue to provide a resource with which your messaging components can interact. For example, suppose you are building an order entry system that places orders into queues as they are received from the sales force or from direct customer interaction on a Web site. You might begin by creating an OrderEntry queue on your Message Queuing enterprise. All of the components you create to process orders will interact with this queue.

There are two ways you can create a queue: by using Server Explorer window or by using the Create constructor from your code. You can use Server Explorer or the Windows 2000 Computer Management window to verify that your queue has been created successfully.

Note   The Servers node of Server Explorer is not available in the Standard Edition of Visual Basic and Visual C# .NET. For more information, see Visual Basic Standard Edition Features or Visual C# Standard Edition Features.

You can create a public queue on your own computer or any Message Queuing computer to which you have domain or enterprise administrative access rights. You can also create private queues on your local computer only. For more information on access rights, see Message Queue Security, or see "Access Control for Message Queuing" in the documentation for the Computer Management dialog box.

Note   It is important to note the difference between creating a queue and creating an instance of the MessageQueue component. When you use the Create constructor, you are creating a new queue in the Message Queuing network, rather than a component in your project or application. When you create an instance of the MessageQueue component, you create a component inside your project that references an existing queue in the operating system.

You can also configure an installation component to create or locate an existing queue when your application is deployed. For more information, see Custom Actions Management in Deployment.

To create a queue from Server Explorer

When you add an instance of the MessageQueue component to your Visual Studio project, the system automatically creates the references and import statements you need to access these namespaces and classes.

  1. Open Server Explorer and access the server on which you want to create a queue. For more information, see Accessing and Initializing Server Explorer.
  2. Right-click the Message Queues node.
  3. Right-click either Public Queues or Private Queues, depending on the type of queue you want to create, and then click Create Queue.
  4. In the Create Message Queue dialog box, type a name for your queue.
  5. If you want to make the queue transactional, select Make Queue Transactional.
    Note   For more information, see Transactional Message Processing.
    Note   Creating a public message queue can take longer than expected if the domain is large and the domain has many domain controllers. This is because it takes time for the new public queue to replicate from your machine's domain controller to all other domain controllers in the domain. You may experience a delay during this replication process.

To create a public queue programmatically

  1. Right-click on the project and select Add Reference. Add a reference to System.Messaging.dll.
  2. Use the Create method to create a public queue on your computer. Your code should look like this:
    ' Visual Basic
    // C#
    Tip   You can use an overload of the Create method to indicate that you want to create a transactional queue. You can also use a period ( . ) in the path to indicate the local machine.
    Security Note   When you create a message queue, be aware that the resource may already exist. Another process, perhaps a malicious one, may have already created the resource and have access to it. When you put data in the message queue, the data is available to the other process. For information on existing queues, see Retrieving Queues.

To create a private queue programmatically

  • Use the Create method, specifying the necessary syntax, Private$, in order to create a private queue on your computer. Your code should look like this:
    ' Visual Basic
    // C#

To verify that your message queue was created

You can use Server Explorer or the Windows 2000 Computer Management window to verify that your message queue was created.

  • In Server Explorer, refresh the Message Queues node by right-clicking Queues and then clicking Refresh. It may take a moment for your queue to appear.

    – or –

  • To see message-queuing information in Windows 2000, follow these steps:
    1. Right-click My Computer on the desktop, and then click Manage.
    2. In the dialog box that appears, expand the Services and Applications node, and then expand Message Queuing. You can find your queue and its messages in this node.

See Also

Creating, Deleting, and Administering Queues | Creating MessageQueue Component Instances