MessageQueue.Path MessageQueue.Path MessageQueue.Path MessageQueue.Path Property

Definición

Obtiene o establece la ruta de acceso a la cola.Gets or sets the queue's path. Al establecer la propiedad Path, el objeto MessageQueue indica una nueva cola.Setting the Path causes the MessageQueue to point to a new queue.

public:
 property System::String ^ Path { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.Messaging.MessagingDescription("MQ_Path")]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.SettingsBindable(true)]
[System.ComponentModel.TypeConverter("System.Diagnostics.Design.StringValueConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string Path { get; set; }
member this.Path : string with get, set
Public Property Path As String

Valor de propiedad

Cola a la que hace referencia el objeto MessageQueue.The queue that is referenced by the MessageQueue. El valor predeterminado depende del constructor MessageQueue() que se utilice; puede ser null o puede ser el valor que especifique el parámetro path del constructor.The default depends on which MessageQueue() constructor you use; it is either null or is specified by the constructor's path parameter.

Excepciones

La ruta de acceso no es válida, posiblemente porque la sintaxis no es válida.The path is not valid, possibly because the syntax is not valid.

Ejemplos

En el ejemplo de código siguiente se crea un nuevo MessageQueue objetos utilizando varios tipos de sintaxis de nombre de ruta de acceso.The following code example creates new MessageQueue objects using various path name syntax types. En cada caso, envía un mensaje a la cola cuya ruta de acceso se define en el constructor.In each case, it sends a message to the queue whose path is defined in the constructor.

#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
ref class MyNewQueue
{
public:

   // References public queues.
   void SendPublic()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );
      myQueue->Send( "Public queue by path name." );
      return;
   }


   // References private queues.
   void SendPrivate()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\Private$\\myQueue" );
      myQueue->Send( "Private queue by path name." );
      return;
   }


   // References queues by label.
   void SendByLabel()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( "Label:TheLabel" );
      myQueue->Send( "Queue by label." );
      return;
   }


   // References queues by format name.
   void SendByFormatName()
   {
      MessageQueue^ myQueue = gcnew MessageQueue( "FormatName:Public=5A5F7535-AE9A-41d4 -935C-845C2AFF7112" );
      myQueue->Send( "Queue by format name." );
      return;
   }


   // References computer journal queues.
   void MonitorComputerJournal()
   {
      MessageQueue^ computerJournal = gcnew MessageQueue( ".\\Journal$" );
      while ( true )
      {
         Message^ journalMessage = computerJournal->Receive();
         
         // Process the journal message.
      }
   }


   // References queue journal queues.
   void MonitorQueueJournal()
   {
      MessageQueue^ queueJournal = gcnew MessageQueue( ".\\myQueue\\Journal$" );
      while ( true )
      {
         Message^ journalMessage = queueJournal->Receive();
         
         // Process the journal message.
      }
   }


   // References dead-letter queues.
   void MonitorDeadLetter()
   {
      MessageQueue^ deadLetter = gcnew MessageQueue( ".\\DeadLetter$" );
      while ( true )
      {
         Message^ deadMessage = deadLetter->Receive();
         
         // Process the dead-letter message.
      }
   }


   // References transactional dead-letter queues.
   void MonitorTransactionalDeadLetter()
   {
      MessageQueue^ TxDeadLetter = gcnew MessageQueue( ".\\XactDeadLetter$" );
      while ( true )
      {
         Message^ txDeadLetter = TxDeadLetter->Receive();
         
         // Process the transactional dead-letter message.
      }
   }

};


//*************************************************
// Provides an entry point into the application.
//         
// This example demonstrates several ways to set
// a queue's path.
//*************************************************
int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   myNewQueue->SendPublic();
   myNewQueue->SendPrivate();
   myNewQueue->SendByLabel();
   myNewQueue->SendByFormatName();
   myNewQueue->MonitorComputerJournal();
   myNewQueue->MonitorQueueJournal();
   myNewQueue->MonitorDeadLetter();
   myNewQueue->MonitorTransactionalDeadLetter();
   return 0;
}

using System;
using System.Messaging;

namespace MyProject
{
	/// <summary>
	/// Provides a container class for the example.
	/// </summary>
	public class MyNewQueue
	{

		//**************************************************
		// Provides an entry point into the application.
		//		 
		// This example demonstrates several ways to set
		// a queue's path.
		//**************************************************

		public static void Main()
		{
			// Create a new instance of the class.
			MyNewQueue myNewQueue = new MyNewQueue();

			myNewQueue.SendPublic();
			myNewQueue.SendPrivate();
			myNewQueue.SendByLabel();
			myNewQueue.SendByFormatName();
			myNewQueue.MonitorComputerJournal();
			myNewQueue.MonitorQueueJournal();
			myNewQueue.MonitorDeadLetter();
			myNewQueue.MonitorTransactionalDeadLetter();

			return;
		}
		
		// References public queues.
		public void SendPublic()
		{
			MessageQueue myQueue = new MessageQueue(".\\myQueue");
			myQueue.Send("Public queue by path name.");

			return;
		}

		// References private queues.
		public void SendPrivate()
		{
			MessageQueue myQueue = new 
				MessageQueue(".\\Private$\\myQueue");
			myQueue.Send("Private queue by path name.");

			return;
		}

		// References queues by label.
		public void SendByLabel()
		{
			MessageQueue myQueue = new MessageQueue("Label:TheLabel");
			myQueue.Send("Queue by label.");

			return;
		}

		// References queues by format name.
		public void SendByFormatName()
		{
			MessageQueue myQueue = new 
				MessageQueue("FormatName:Public=5A5F7535-AE9A-41d4" + 
				"-935C-845C2AFF7112");
			myQueue.Send("Queue by format name.");

			return;
		}

		// References computer journal queues.
		public void MonitorComputerJournal()
		{
			MessageQueue computerJournal = new 
				MessageQueue(".\\Journal$");
			while(true)
			{
				Message journalMessage = computerJournal.Receive();
				// Process the journal message.
			}
		}

		// References queue journal queues.
		public void MonitorQueueJournal()
		{
			MessageQueue queueJournal = new 
				MessageQueue(".\\myQueue\\Journal$");
			while(true)
			{
				Message journalMessage = queueJournal.Receive();
				// Process the journal message.
			}
		}
		
		// References dead-letter queues.
		public void MonitorDeadLetter()
		{
			MessageQueue deadLetter = new 
				MessageQueue(".\\DeadLetter$");
			while(true)
			{
				Message deadMessage = deadLetter.Receive();
				// Process the dead-letter message.
			}
		}

		// References transactional dead-letter queues.
		public void MonitorTransactionalDeadLetter()
		{
			MessageQueue TxDeadLetter = new 
				MessageQueue(".\\XactDeadLetter$");
			while(true)
			{
				Message txDeadLetter = TxDeadLetter.Receive();
				// Process the transactional dead-letter message.
			}
		}

	}
}
Imports System
Imports System.Messaging

Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '		 
        ' This example demonstrates several ways to set
        ' a queue's path.
        

        Public Shared Sub Main()

            ' Create a new instance of the class.
            Dim myNewQueue As New MyNewQueue()

            myNewQueue.SendPublic()
            myNewQueue.SendPrivate()
            myNewQueue.SendByLabel()
            myNewQueue.SendByFormatName()
            myNewQueue.MonitorComputerJournal()
            myNewQueue.MonitorQueueJournal()
            myNewQueue.MonitorDeadLetter()
            myNewQueue.MonitorTransactionalDeadLetter()

            Return

        End Sub 'Main


        ' References public queues.
        Public Sub SendPublic()

            Dim myQueue As New MessageQueue(".\myQueue")
            myQueue.Send("Public queue by path name.")

            Return

        End Sub 'SendPublic


        ' References private queues.
        Public Sub SendPrivate()

            Dim myQueue As New MessageQueue(".\Private$\myQueue")
            myQueue.Send("Private queue by path name.")

            Return

        End Sub 'SendPrivate


        ' References queues by label.
        Public Sub SendByLabel()

            Dim myQueue As New MessageQueue("Label:TheLabel")
            myQueue.Send("Queue by label.")

            Return

        End Sub 'SendByLabel


        ' References queues by format name.
        Public Sub SendByFormatName()

            Dim myQueue As New _
                MessageQueue("FormatName:Public=" + _
                    "5A5F7535-AE9A-41d4-935C-845C2AFF7112")
            myQueue.Send("Queue by format name.")

            Return

        End Sub 'SendByFormatName


        ' References computer journal queues.
        Public Sub MonitorComputerJournal()

            Dim computerJournal As New MessageQueue(".\Journal$")

            While True

                Dim journalMessage As Message = _
                    computerJournal.Receive()

                ' Process the journal message.

            End While

            Return
        End Sub 'MonitorComputerJournal


        ' References queue journal queues.
        Public Sub MonitorQueueJournal()

            Dim queueJournal As New _
                            MessageQueue(".\myQueue\Journal$")

            While True

                Dim journalMessage As Message = _
                    queueJournal.Receive()

                ' Process the journal message.

            End While

            Return
        End Sub 'MonitorQueueJournal


        ' References dead-letter queues.
        Public Sub MonitorDeadLetter()
            Dim deadLetter As New MessageQueue(".\DeadLetter$")

            While True

                Dim deadMessage As Message = deadLetter.Receive()

                ' Process the dead-letter message.

            End While

            Return

        End Sub 'MonitorDeadLetter


        ' References transactional dead-letter queues.
        Public Sub MonitorTransactionalDeadLetter()

            Dim TxDeadLetter As New MessageQueue(".\XactDeadLetter$")

            While True

                Dim txDeadLetterMessage As Message = _
                    TxDeadLetter.Receive()

                ' Process the transactional dead-letter message.

            End While

            Return

        End Sub 'MonitorTransactionalDeadLetter

End Class 'MyNewQueue 

Comentarios

La sintaxis para el Path propiedad depende del tipo de cola que puntos a, tal como se muestra en la tabla siguiente.The syntax for the Path property depends on the type of queue it points to, as shown in the following table.

Tipo de colaQueue type SintaxisSyntax
cola públicaPublic queue MachineName\QueueName
cola privadaPrivate queue MachineName\Private$\QueueName
Cola de diarioJournal queue MachineName\QueueName\Journal$
Cola de diario del equipoMachine journal queue MachineName\Journal$
Cola de mensajes no enviados del equipoMachine dead-letter queue MachineName\Deadletter$
Cola de mensajes no enviados transaccional del equipoMachine transactional dead-letter queue MachineName\XactDeadletter$

Use "." para representar el equipo local.Use "." to represent the local computer.

El MachineName, Path, y QueueName propiedades están relacionadas.The MachineName, Path, and QueueName properties are related. Cambiar el MachineName propiedad causa el Path propiedad que se va a cambiar.Changing the MachineName property causes the Path property to change. Se crea a partir de la nueva MachineName y QueueName.It is built from the new MachineName and the QueueName. Cambiar el Path (por ejemplo, para utilizar la sintaxis de nombre de formato) restablece el MachineName y QueueName propiedades para hacer referencia a la nueva cola.Changing the Path (for example, to use the format name syntax) resets the MachineName and QueueName properties to refer to the new queue.

Como alternativa, puede usar el FormatName o Label para describir la ruta de acceso de la cola, como se muestra en la tabla siguiente.Alternatively, you can use the FormatName or Label to describe the queue path, as shown in the following table.

ReferenciaReference SintaxisSyntax EjemploExample
Nombre de formatoFormat name FormatName: [ nombre de formato ]FormatName: [ format name ] FormatName:Public= 5A5F7535-AE9A-41d4-935C-845C2AFF7112FormatName:Public= 5A5F7535-AE9A-41d4-935C-845C2AFF7112
EtiquetaLabel Label: [ etiqueta ]Label: [ label ] Label: EtiquetaLabel: TheLabel

Si usa la sintaxis de etiqueta para el Path propiedad al enviar el mensaje, una excepción se producirá si el Label no es único.If you use the label syntax for the Path property when you send the message, an exception will be thrown if the Label is not unique.

Para trabajar sin conexión, debe usar la sintaxis del nombre de formato, en lugar de la sintaxis del nombre descriptivo de la primera tabla.To work offline, you must use the format name syntax, rather than the friendly name syntax in the first table. En caso contrario, se produce una excepción porque el controlador de dominio principal (en el que reside Active Directory) no está disponible para resolver la ruta de acceso en el nombre de formato.Otherwise, an exception is thrown because the primary domain controller (on which Active Directory resides) is not available to resolve the path to the format name.

Establecer una nueva ruta de acceso cierra la cola de mensajes y libera todos los identificadores.Setting a new path closes the message queue and releases all handles.

En la tabla siguiente se muestra si esta propiedad está disponible en los distintos modos de grupo de trabajo.The following table shows whether this property is available in various Workgroup modes.

Modo de grupo de trabajoWorkgroup mode DisponibleAvailable
Equipo localLocal computer Yes
Equipo local y el nombre de formato directoLocal computer and direct format name Yes
Equipo remotoRemote computer Yes
Equipo remoto y el nombre de formato directoRemote computer and direct format name Yes

Nota

En modo de grupo de trabajo sólo se pueden utilizar las colas privadas.In workgroup mode you can only use private queues. Especifique la ruta de acceso mediante la sintaxis de la cola privada MachineName \ Private$ \ QueueName.You specify the path using the private queue syntax MachineName\Private$\QueueName.

Se aplica a

Consulte también: