NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MessageQueue.Create (String, Boolean)

Creates a transactional or nontransactional Message Queuing backend queue resource with the specified path.

[Visual Basic]
Overloads Public Shared Function Create( _
   ByVal path As String, _
   ByVal transactional As Boolean _
) As MessageQueue
[C#]
public static MessageQueue Create(
   string path,
   bool transactional
);
[C++]
public: static MessageQueue* Create(
   String* path,
   bool transactional
);
[JScript]
public static function Create(
   path : String,
   transactional : Boolean
) : MessageQueue;

Parameters

path
The path of the queue to be created, using "." for the local computer. For information on proper syntax for this parameter, see the Remarks section .
transactional
true to create a transactional queue; false to create a nontransactional queue.

Return Value

A MessageQueue that represents the new queue.

Exceptions

Exception Type Condition
ArgumentException The path parameter is a null reference (in Visual Basic Nothing) or an empty string.
MessageQueueException The path parameter is not unique.
MessageQueueException The attempt to access the queue's Formatter property while creating a new queue generated an exception specified by the given status message.

Remarks

Use this overload to create a transactional backend queue resource. You can create a nontransactional resource by setting the transactional parameter to false.

To instantiate a new MessageQueue within your application, use the constructor. Call Create to create a new resource in Message Queuing.

If you declare a MessageQueue, it is not necessary to instantiate it through a call to the constructor in addition to the call to Create. Create instantiates a MessageQueue automatically.

The syntax for the path parameter depends on the type of queue it references. The following table shows the syntax you should use for a queue of a specified type.

Queue Type Syntax
Public Queue MachineName\QueueName
Private Queue MachineName\Private$\QueueName

Example [Visual Basic]

The following example verifies whether a queue named "myNewQueue" exists on the local computer. If it doesn't, one is created and set to be transactional. If a queue named "myNewQueue" already exists, it is examined to see if it is transactional.

If the queue is transactional or was created by the procedure (and hence is transactional), a message is sent to the queue.

[Visual Basic]

Private Sub CreateTransactionalQueue(ByVal msg As Message)
    'Define a new MessageQueue.
    Dim messageQueue1 As MessageQueue

    If Not MessageQueue.Exists(".\myNewQueue") Then
        'Create a new transactional queue on the local computer.
        messageQueue1 = MessageQueue.Create(".\myNewQueue", True)
    Else
        'The queue exists already. Verify that it is transactional.
        messageQueue1 = New MessageQueue(".\myNewQueue")
        If Not messageQueue1.Transactional Then
Exit Sub
        End If
    End If

    'Send a message to the queue.
    messageQueue1.Send(msg)
End Sub

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace | MessageQueue.Create Overload List | Path | MessageQueue | Delete | Refresh | MessageQueue | Transactional