Creates a nontransactional Message Queuing backend queue resource with the specified path.
[Visual Basic] Overloads Public Shared Function Create( _ ByVal path As String _ ) As MessageQueue [C#] public static MessageQueue Create( string path ); [C++] public: static MessageQueue* Create( String* path ); [JScript] public static function Create( path : String ) : MessageQueue;
A MessageQueue that represents the new queue.
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. |
Use this overload to create nontransactional backend queue resource.
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 |
Use "." for the local computer.
The following example examines a queue passed in, and creates a queue named "myNewQueue" on the same computer. It then sends a message to the queue.
[Visual Basic]
Private Sub CreateQueueOnComputer(ByVal currentQueuePath As String) 'Define a new MessageQueue. Dim messageQueue1 As MessageQueue Dim newQueue As MessageQueue 'Instantiate a MessageQueue using the currentQueuePath. messageQueue1 = New MessageQueue(currentQueuePath) 'Create a new queue on the same computer. newQueue = MessageQueue.Create(messageQueue1.MachineName + "\myNewQueue") newQueue.Send("Test Message") End Sub
MessageQueue Class | MessageQueue Members | System.Messaging Namespace | MessageQueue.Create Overload List | Path | MessageQueue | Delete | Refresh