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.MachineName

Gets or sets the name of the computer where the queue referenced by this MessageQueue is located.

[Visual Basic]
Overridable Public Property MachineName As String
[C#]
public string MachineName {virtual get; virtual set;}
[C++]
public: __property virtual String* get_MachineName();
public: __property virtual void set_MachineName(String*);
[JScript]
public function get MachineName() : String;
public function set MachineName(String);

Property Value

The name of the computer on which the queue is located. The Message Queuing default is ".", the local computer.

Exceptions

Exception Type Condition
ArgumentException The MachineName is a null reference (in Visual Basic Nothing).
ArgumentException The computer name was set to an invalid value. The syntax may be incorrect.
MessageQueueException The attempt to get or set the machine name generated an internal error on the message queue component. The error is specified by the given status message.

Remarks

If you don't specify a value for the Path when the MachineName is set, the path is built from an existing queue. If you have not specified the format name either (from which a path could be built), the path defaults to the local journal queue.

Message Queuing can send and receive messages from any public queue on the network. You can search for public queues across the network with a variety of criteria, such as Category or LastModifyTime, but you must specify a computer when searching for private queues.

The MachineName is integral to defining queue paths by common names. When working online, the domain controller's Active Directory associates the common name for the Path with the path's unique FormatName. The syntax for the Path property 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
Journal Queue MachineName\QueueName\Journal$
Machine Journal Queue MachineName\Journal$
Machine DeadLetter Queue MachineName\Deadletter$
Machine Transactional Deadletter Queue MachineName\XactDeadletter$

Use "." for the local computer when specifying the MachineName.

Because the domain controller is required for path translation, defining the Path in terms of the MachineName throws an exception when working off-line. FormatName is required in the Path syntax when working off-line.

Example [Visual Basic]

The following example passes in a queue and creates a queue with the name "myNewQueue" on the same computer. The computer is determined by the queue passed in. This example assumes that a queue named "myNewQueue" does not already exist on the specified computer.

Import the System.Messaging namespace for this example.

[Visual Basic]

Private Sub CreateQueueOnComputer(ByVal currentQueuePath As String)
    Dim computer As String
    'Define a new MessageQueue.
    Dim messageQueue1 As MessageQueue

    'Instantiate a MessageQueue using the currentQueuePath.
    messageQueue1 = New MessageQueue(currentQueuePath)
    'Get the name of the computer from the queue.
    computer = messageQueue1.MachineName

    'Create a new queue on the same computer.
    MessageQueue.Create(computer + "\myNewQueue")
End Sub

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace | QueueName | Path | FormatName | GetPrivateQueuesByMachine | GetPublicQueuesByMachine | GetPublicQueues