Gets the unique name that was generated for the queue when the queue was created.
[Visual Basic] Overridable Public ReadOnly Property FormatName As String [C#] public string FormatName {virtual get;} [C++] public: __property virtual String* get_FormatName(); [JScript] public function get FormatName() : String;
The unique name for the queue, generated by the Message Queuing application when the queue was created.
Exception Type | Condition |
---|---|
MessageQueueException | The Path is not set.
-or- There is a problem connecting to the network. |
The FormatName property specifies the format name of the queue. This property or the Path property must be set before accessing the queue. Message Queuing uses the queue's format name to identify which queue to open and how to access the opened queue. If you specify a path such as myComputer\myQueue, rather than the format name, the primary domain controller translates the Path into the associated FormatName before accessing the queue. Unlike most of the characteristics of a queue, the format name is not a Message Queuing application queue property that can be accessed through the Message Queuing management tool. It is simply a unique name for the queue that is generated by Message Queuing when the queue is created or generated later by the application.
When creating a queue, Message Queuing generates the format name from the queue's path name. After the queue is created, you can use the name generated by the Message Queuing application or specify a different one.
The following example demonstrates using the queue's FormatName to set the Path property. Because FormatName is read-only, the procedure does not set the FormatName property; instead the procedure reads and appends the FormatName to the string "FormatName:Public=" in order to define the path. This procedure assumes that the Id value passed in represents a valid public queue. The ID of a queue can be retrieved using the Message Queuing application.
[Visual Basic]
Private Sub SendUsingQueueFormat(ByVal queueId As System.Guid) 'The queue path, to be generated from the queue Id. Dim queuePath As String 'Define a new MessageQueue. Dim messageQueue1 As MessageQueue 'Generate the path using the FormatName. queuePath = "FormatName:PUBLIC=" + queueId.ToString 'Instantiate a MessageQueue with the specified path. messageQueue1 = New MessageQueue(queuePath) 'Send a message to the queue. messageQueue1.Send("Test Message") End Sub
MessageQueue Class | MessageQueue Members | System.Messaging Namespace | Path | Label | MessageQueue