MessageQueueCriteria Clase

Definición

Filtra las colas de mensajes cuando se realiza una consulta mediante el método MessageQueue de la clase GetPublicQueues().

public ref class MessageQueueCriteria
public class MessageQueueCriteria
type MessageQueueCriteria = class
Public Class MessageQueueCriteria
Herencia
MessageQueueCriteria

Ejemplos

En el ejemplo siguiente se recorren en iteración las colas de mensajes y se muestra la ruta de acceso de cada cola que se creó en el último día y que existe en el equipo "MyComputer".

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

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

   // Iterates through message queues and displays the
   // path of each queue that was created in the last
   // day and that exists on the computer "MyComputer". 
   void ListPublicQueuesByCriteria()
   {
      UInt32 numberQueues = 0;
      
      // Specify the criteria to filter by.
      MessageQueueCriteria^ myCriteria = gcnew MessageQueueCriteria;
      myCriteria->MachineName = "MyComputer";
      myCriteria->CreatedAfter = DateTime::Now.Subtract( TimeSpan(1,0,0,0) );
      
      // Get a cursor into the queues on the network.
      MessageQueueEnumerator^ myQueueEnumerator = MessageQueue::GetMessageQueueEnumerator( myCriteria );
      
      // Move to the next queue and read its path.
      while ( myQueueEnumerator->MoveNext() )
      {
         
         // Increase the count if priority is Lowest.
         Console::WriteLine( myQueueEnumerator->Current->Path );
         numberQueues++;
      }

      
      // Handle no queues matching the criteria.
      if ( numberQueues == 0 )
      {
         Console::WriteLine( "No public queues match criteria." );
      }

      return;
   }

};

int main()
{
   
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;
   
   // Output the count of Lowest priority messages.
   myNewQueue->ListPublicQueuesByCriteria();
   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 uses a cursor to step through the
        // message queues and list the public queues on the
        // network that specify certain criteria.
        //**************************************************

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

            // Output the count of Lowest priority messages.
            myNewQueue.ListPublicQueuesByCriteria();
                        
            return;
        }

        //**************************************************
        // Iterates through message queues and displays the
        // path of each queue that was created in the last
        // day and that exists on the computer "MyComputer".
        //**************************************************
        
        public void ListPublicQueuesByCriteria()
        {
            uint numberQueues = 0;
            
            // Specify the criteria to filter by.
            MessageQueueCriteria myCriteria = new
                MessageQueueCriteria();
            myCriteria.MachineName = "MyComputer";
            myCriteria.CreatedAfter = DateTime.Now.Subtract(new
                TimeSpan(1,0,0,0));

            // Get a cursor into the queues on the network.
            MessageQueueEnumerator myQueueEnumerator =
                MessageQueue.GetMessageQueueEnumerator(myCriteria);

            // Move to the next queue and read its path.
            while(myQueueEnumerator.MoveNext())
            {
                // Increase the count if priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path);
                numberQueues++;
            }

            // Handle no queues matching the criteria.
            if (numberQueues == 0)
            {
                Console.WriteLine("No public queues match criteria.");
            }

            return;
        }
    }
}
Imports System.Messaging

 
Public Class MyNewQueue


        '
        ' Provides an entry point into the application.
        '		 
        ' This example uses a cursor to step through the
        ' message queues and list the public queues on the
        ' network that specify certain criteria.
        

        Public Shared Sub Main()

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

            ' Output the count of Lowest priority messages.
            myNewQueue.ListPublicQueuesByCriteria()

            Return

        End Sub


        
        ' Iterates through message queues and displays the
        ' path of each queue that was created in the last
        ' day and that exists on the computer "MyComputer". 
        

        Public Sub ListPublicQueuesByCriteria()

            Dim numberQueues As Int32 = 0

            ' Specify the criteria to filter by.
            Dim myCriteria As New MessageQueueCriteria()
            myCriteria.MachineName = "MyComputer"
            myCriteria.CreatedAfter = DateTime.Now.Subtract(New _
                TimeSpan(1, 0, 0, 0))


            ' Get a cursor into the queues on the network.
            Dim myQueueEnumerator As MessageQueueEnumerator = _
                MessageQueue.GetMessageQueueEnumerator(myCriteria)

            ' Move to the next queue and read its path.
            While myQueueEnumerator.MoveNext()
                ' Increase the count if the priority is Lowest.
                Console.WriteLine(myQueueEnumerator.Current.Path)
                numberQueues += 1
            End While

            ' Handle no queues matching the criteria.
            If numberQueues = 0 Then
                Console.WriteLine("No queues match the criteria.")
            End If

            Return

        End Sub

End Class

Comentarios

La MessageQueue clase proporciona una serie de métodos que permiten filtrar la búsqueda de colas públicas en la red. Los métodos específicos para filtrar por etiqueta de cola, categoría o ubicación del servidor son , GetPublicQueuesByLabelGetPublicQueuesByCategoryy GetPublicQueuesByMachine.

La MessageQueueCriteria clase , cuando se usa con el GetPublicQueues método , le permite refinar el filtro. Puede especificar criterios de búsqueda que no se abordan específicamente a través de uno de los GetPublicQueuesBymétodos * o por varios criterios. Puede pasar una MessageQueueCriteria instancia al GetPublicQueues método para buscar, por ejemplo, mediante la creación o los tiempos de modificación de la cola, el equipo en el que reside la cola, la etiqueta o la categoría de la cola, o cualquier combinación de estas propiedades.

Al filtrar por varias propiedades, los criterios se componen aplicando el AND operador al conjunto de propiedades. Por lo tanto, al especificar un valor para la CreatedAfter propiedad junto con la MachineName propiedad , solicita todas las colas que se crearon después de una hora especificada y que residen en un equipo específico.

Al establecer cualquier propiedad, el método que establece la propiedad también establece una marca para indicar que debe incluirse en el filtro que está compilando. No se pueden quitar propiedades individuales del filtro de búsqueda. En su lugar, quite todas las propiedades del filtro llamando a ClearAlly, a continuación, establezca las propiedades que desea compilar en el filtro de búsqueda. ClearAll restablece todas las propiedades en un estado predeterminado "no establecido".

Debe establecer una propiedad antes de intentar leerla; de lo contrario, se produce una excepción.

Constructores

MessageQueueCriteria()

Inicializa una nueva instancia de la clase MessageQueueCriteria.

Propiedades

Category

Obtiene o establece la categoría por la que se filtran las colas en la red.

CreatedAfter

Obtiene o establece el límite inferior de la fecha y hora de creación de la cola que se utilizará para filtrar las colas en la red.

CreatedBefore

Obtiene o establece el límite superior de la fecha y hora de creación de la cola que se utilizará para filtrar las colas en la red.

Label

Obtiene o establece la etiqueta por la que se filtran las colas en la red.

MachineName

Obtiene o establece el nombre del equipo por el que se filtran las colas en la red.

ModifiedAfter

Obtiene o establece el límite inferior de la fecha y hora de modificación de la cola que se utilizará para filtrar las colas en la red.

ModifiedBefore

Obtiene o establece el límite superior de la fecha y hora de modificación de la cola que se utilizará para filtrar las colas en la red.

Métodos

ClearAll()

Borra todas las propiedades que se van a integrar en un filtro y asigna el estado de "sin establecer" a todos los valores de propiedad.

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.

(Heredado de Object)
GetHashCode()

Sirve como la función hash predeterminada.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.

(Heredado de Object)

Se aplica a

Consulte también