MessagePropertyFilter Klasa

Definicja

Steruje i wybiera właściwości, które są pobierane podczas wglądu lub odbierania komunikatów z kolejki komunikatów.

public ref class MessagePropertyFilter
public ref class MessagePropertyFilter : ICloneable
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class MessagePropertyFilter
[System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))]
public class MessagePropertyFilter : ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
type MessagePropertyFilter = class
[<System.ComponentModel.TypeConverter(typeof(System.ComponentModel.ExpandableObjectConverter))>]
type MessagePropertyFilter = class
    interface ICloneable
Public Class MessagePropertyFilter
Public Class MessagePropertyFilter
Implements ICloneable
Dziedziczenie
MessagePropertyFilter
Atrybuty
Implementuje

Przykłady

Poniższy przykład kodu wysyła dwa komunikaty o różnych priorytetach do kolejki i pobiera je później.


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

using namespace System;
using namespace System::Messaging;

/// <summary>
/// Provides a container class for the example.
/// </summary>
ref class MyNewQueue
{
   //**************************************************
   // Sends a string message to a queue.
   //**************************************************
public:
   void SendMessage( MessagePriority priority, String^ messageBody )
   {
      // Connect to a queue on the local computer.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

      // Create a new message.
      Message^ myMessage = gcnew Message;
      if ( priority > MessagePriority::Normal )
      {
         myMessage->Body = "High Priority: {0}",messageBody;
      }
      else
      {
         myMessage->Body = messageBody;
      }

      // Set the priority of the message.
      myMessage->Priority = priority;

      // Send the Order to the queue.
      myQueue->Send( myMessage );

      return;
   }

   //**************************************************
   // Receives a message.
   //**************************************************
   void ReceiveMessage()
   {
      // Connect to the a queue on the local computer.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

      // Set the queue to read the priority. By default, it
      // is not read.
      myQueue->MessageReadPropertyFilter->Priority = true;

      // Set the formatter to indicate body contains a String^.
      array<Type^>^ p = gcnew array<Type^>(1);
      p[ 0 ] = String::typeid;
      myQueue->Formatter = gcnew XmlMessageFormatter( p );
      try
      {
         // Receive and format the message. 
         Message^ myMessage = myQueue->Receive();

         // Display message information.
         Console::WriteLine( "Priority: {0}",
            myMessage->Priority );
         Console::WriteLine( "Body: {0}",
            myMessage->Body );
      }
      catch ( MessageQueueException^ ) 
      {
         // Handle Message Queuing exceptions.
      }
      // Handle invalid serialization format.
      catch ( InvalidOperationException^ e ) 
      {
         Console::WriteLine( e->Message );
      }

      // Catch other exceptions as necessary.

      return;
   }
};

//**************************************************
// Provides an entry point into the application.
//		 
// This example sends and receives a message from
// a queue.
//**************************************************
int main()
{
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;

   // Send messages to a queue.
   myNewQueue->SendMessage( MessagePriority::Normal, "First Message Body." );
   myNewQueue->SendMessage( MessagePriority::Highest, "Second Message Body." );

   // Receive messages from a queue.
   myNewQueue->ReceiveMessage();
   myNewQueue->ReceiveMessage();

   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 sends and receives a message from
        // a queue.
        //**************************************************

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

            // Send messages to a queue.
            myNewQueue.SendMessage(MessagePriority.Normal, "First Message Body.");
            myNewQueue.SendMessage(MessagePriority.Highest, "Second Message Body.");

            // Receive messages from a queue.
            myNewQueue.ReceiveMessage();
            myNewQueue.ReceiveMessage();

            return;
        }

        //**************************************************
        // Sends a string message to a queue.
        //**************************************************
        
        public void SendMessage(MessagePriority priority, string messageBody)
        {

            // Connect to a queue on the local computer.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            // Create a new message.
            Message myMessage = new Message();

            if(priority > MessagePriority.Normal)
            {
                myMessage.Body = "High Priority: " + messageBody;
            }
            else
            {
                myMessage.Body = messageBody;
            }

            // Set the priority of the message.
            myMessage.Priority = priority;

            // Send the Order to the queue.
            myQueue.Send(myMessage);

            return;
        }

        //**************************************************
        // Receives a message.
        //**************************************************
        
        public  void ReceiveMessage()
        {
            // Connect to the a queue on the local computer.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            // Set the queue to read the priority. By default, it
            // is not read.
            myQueue.MessageReadPropertyFilter.Priority = true;

            // Set the formatter to indicate body contains a string.
            myQueue.Formatter = new XmlMessageFormatter(new Type[]
                {typeof(string)});
            
            try
            {
                // Receive and format the message.
                Message myMessage =	myQueue.Receive();

                // Display message information.
                Console.WriteLine("Priority: " +
                    myMessage.Priority.ToString());
                Console.WriteLine("Body: " +
                    myMessage.Body.ToString());
            }
            
            catch (MessageQueueException)
            {
                // Handle Message Queuing exceptions.
            }

            // Handle invalid serialization format.
            catch (InvalidOperationException e)
            {
                Console.WriteLine(e.Message);
            }
            
            // Catch other exceptions as necessary.

            return;
        }
    }
}
Imports System.Messaging


'Provides a container class for the example.
Public Class MyNewQueue
      
      

      ' Provides an entry point into the application.
      '		 
      ' This example sends and receives a message from
      ' a queue.

      Public Shared Sub Main()
         ' Create a new instance of the class.
         Dim myNewQueue As New MyNewQueue()
         
         ' Send messages to a queue.
         myNewQueue.SendMessage(MessagePriority.Normal, "First Message Body.")
         myNewQueue.SendMessage(MessagePriority.Highest, "Second Message Body.")
         
         ' Receive messages from a queue.
         myNewQueue.ReceiveMessage()
         myNewQueue.ReceiveMessage()
         
         Return
      End Sub
      
      
      

      ' Sends a string message to a queue.

      Public Sub SendMessage(priority As MessagePriority, messageBody As String)
         
         ' Connect to a queue on the local computer.
         Dim myQueue As New MessageQueue(".\myQueue")
         
         ' Create a new message.
         Dim myMessage As New Message()
         
         If priority > MessagePriority.Normal Then
            myMessage.Body = "High Priority: " + messageBody
         Else
            myMessage.Body = messageBody
         End If 
         ' Set the priority of the message.
         myMessage.Priority = priority
         
         
         ' Send the Order to the queue.
         myQueue.Send(myMessage)
         
         Return
      End Sub
      
      
      

      ' Receives a message.

      Public Sub ReceiveMessage()
         ' Connect to the a queue on the local computer.
         Dim myQueue As New MessageQueue(".\myQueue")
         
         ' Set the queue to read the priority. By default, it
         ' is not read.
         myQueue.MessageReadPropertyFilter.Priority = True
         
         ' Set the formatter to indicate body contains a string.
         myQueue.Formatter = New XmlMessageFormatter(New Type() {GetType(String)})
         
         Try
            ' Receive and format the message. 
            Dim myMessage As Message = myQueue.Receive()
            
            ' Display message information.
            Console.WriteLine(("Priority: " + myMessage.Priority.ToString()))
            Console.WriteLine(("Body: " + myMessage.Body.ToString()))
         
         
         
         ' Handle invalid serialization format.
         Catch e As InvalidOperationException
            Console.WriteLine(e.Message)
         End Try
         
         ' Catch other exceptions as necessary.
         Return
      End Sub
   End Class

Uwagi

MessagePropertyFilter Ustawienie właściwości w wystąpieniu MessageQueue steruje zestawem właściwości, które są pobierane podczas podglądu lub odbierania komunikatu. Filtr jest ustawiany na wystąpieniu MessageQueue , które pobiera informacje o komunikacie. Po ustawieniu elementu członkowskiego z wartością MessagePropertyFilter logiczną na wartość nie można zapobiec pobieraniu informacji o skojarzonej Message właściwości przez element MessageQueue.false

Istnieje kilka właściwości filtru, które nie są wartościami logicznymi. Są to wartości całkowite, które pobierają lub ustawiają domyślne rozmiary Message.Body, Message.Extensionlub Message.Label.

Pobieranie ograniczonego zestawu właściwości pomaga zwiększyć wydajność, ponieważ mniejsze ilości danych są przesyłane z kolejki.

Podczas ustawiania właściwości w systemie MessagePropertyFilterwskazujesz tylko, czy ta właściwość jest pobierana po odebraniu komunikatu, czy podejrzyj. Nie zmieniasz skojarzonej wartości właściwości dla elementu Message.

Konstruktor MessagePropertyFilter ustawia wszystkie właściwości filtru na wartości domyślne, które dla wartości logicznych to false. Zobacz temat konstruktora, aby zapoznać się z wartościami domyślnymi przypisanymi do właściwości typu liczba całkowita.

Konstruktory

MessagePropertyFilter()

Inicjuje MessagePropertyFilter nowe wystąpienie klasy i ustawia wartości domyślne dla wszystkich właściwości.

Właściwości

AcknowledgeType

Pobiera lub ustawia wartość wskazującą, czy pobierać AcknowledgeType informacje o właściwości podczas odbierania lub przeglądania komunikatu.

Acknowledgment

Pobiera lub ustawia wartość wskazującą, czy pobierać Acknowledgment informacje o właściwości podczas odbierania lub przeglądania komunikatu.

AdministrationQueue

Pobiera lub ustawia wartość wskazującą, czy pobierać AdministrationQueue informacje o właściwości podczas odbierania lub przeglądania komunikatu.

AppSpecific

Pobiera lub ustawia wartość wskazującą, czy pobierać AppSpecific informacje o właściwości podczas odbierania lub przeglądania komunikatu.

ArrivedTime

Pobiera lub ustawia wartość wskazującą, czy pobierać ArrivedTime informacje o właściwości podczas odbierania lub przeglądania komunikatu.

AttachSenderId

Pobiera lub ustawia wartość wskazującą, czy pobierać AttachSenderId informacje o właściwości podczas odbierania lub przeglądania komunikatu.

Authenticated

Pobiera lub ustawia wartość wskazującą, czy pobierać Authenticated informacje o właściwości podczas odbierania lub przeglądania komunikatu.

AuthenticationProviderName

Pobiera lub ustawia wartość wskazującą, czy pobierać AuthenticationProviderName informacje o właściwości podczas odbierania lub przeglądania komunikatu.

AuthenticationProviderType

Pobiera lub ustawia wartość wskazującą, czy pobierać AuthenticationProviderType informacje o właściwości podczas odbierania lub przeglądania komunikatu.

Body

Pobiera lub ustawia wartość wskazującą, czy pobierać Body informacje o właściwości podczas odbierania lub przeglądania komunikatu.

ConnectorType

Pobiera lub ustawia wartość wskazującą, czy pobierać ConnectorType informacje o właściwości podczas odbierania lub przeglądania komunikatu.

CorrelationId

Pobiera lub ustawia wartość wskazującą, czy pobierać CorrelationId informacje o właściwości podczas odbierania lub przeglądania komunikatu.

DefaultBodySize

Pobiera lub ustawia rozmiar w bajtach domyślnego bufora treści.

DefaultExtensionSize

Pobiera lub ustawia rozmiar w bajtach domyślnego bufora rozszerzenia.

DefaultLabelSize

Pobiera lub ustawia rozmiar w bajtach domyślnego bufora etykiety.

DestinationQueue

Pobiera lub ustawia wartość wskazującą, czy pobierać DestinationQueue informacje o właściwości podczas odbierania lub przeglądania komunikatu.

DestinationSymmetricKey

Pobiera lub ustawia wartość wskazującą, czy pobierać DestinationSymmetricKey informacje o właściwości podczas odbierania lub przeglądania komunikatu.

DigitalSignature

Pobiera lub ustawia wartość wskazującą, czy pobierać DigitalSignature informacje o właściwości podczas odbierania lub przeglądania komunikatu.

EncryptionAlgorithm

Pobiera lub ustawia wartość wskazującą, czy pobierać EncryptionAlgorithm informacje o właściwości podczas odbierania lub przeglądania komunikatu.

Extension

Pobiera lub ustawia wartość wskazującą, czy pobierać Extension informacje o właściwości podczas odbierania lub przeglądania komunikatu.

HashAlgorithm

Pobiera lub ustawia wartość wskazującą, czy pobierać HashAlgorithm informacje o właściwości podczas odbierania lub przeglądania komunikatu.

Id

Pobiera lub ustawia wartość wskazującą, czy pobierać Id informacje o właściwości podczas odbierania lub przeglądania komunikatu.

IsFirstInTransaction

Pobiera lub ustawia wartość wskazującą, czy pobierać IsFirstInTransaction informacje o właściwości podczas odbierania lub przeglądania komunikatu.

IsLastInTransaction

Pobiera lub ustawia wartość wskazującą, czy pobierać IsLastInTransaction informacje o właściwości podczas odbierania lub przeglądania komunikatu.

Label

Pobiera lub ustawia wartość wskazującą, czy pobierać Label informacje o właściwości podczas odbierania lub przeglądania komunikatu.

LookupId

Pobiera lub ustawia wartość wskazującą, czy pobierać LookupId informacje o właściwości podczas odbierania lub przeglądania komunikatu.

MessageType

Pobiera lub ustawia wartość wskazującą, czy pobierać MessageType informacje o właściwości podczas odbierania lub podglądu komunikatu.

Priority

Pobiera lub ustawia wartość wskazującą, czy pobierać Priority informacje o właściwości podczas odbierania lub podglądu komunikatu.

Recoverable

Pobiera lub ustawia wartość wskazującą, czy pobierać Recoverable informacje o właściwości podczas odbierania lub podglądu komunikatu.

ResponseQueue

Pobiera lub ustawia wartość wskazującą, czy pobierać ResponseQueue informacje o właściwości podczas odbierania lub podglądu komunikatu.

SenderCertificate

Pobiera lub ustawia wartość wskazującą, czy pobierać SenderCertificate informacje o właściwości podczas odbierania lub podglądu komunikatu.

SenderId

Pobiera lub ustawia wartość wskazującą, czy pobierać SenderId informacje o właściwości podczas odbierania lub podglądu komunikatu.

SenderVersion

Pobiera lub ustawia wartość wskazującą, czy pobierać SenderVersion informacje o właściwości podczas odbierania lub podglądu komunikatu.

SentTime

Pobiera lub ustawia wartość wskazującą, czy pobierać SentTime informacje o właściwości podczas odbierania lub podglądu komunikatu.

SourceMachine

Pobiera lub ustawia wartość wskazującą, czy pobierać SourceMachine informacje o właściwości podczas odbierania lub podglądu komunikatu.

TimeToBeReceived

Pobiera lub ustawia wartość wskazującą, czy pobierać TimeToBeReceived informacje o właściwości podczas odbierania lub podglądu komunikatu.

TimeToReachQueue

Pobiera lub ustawia wartość wskazującą, czy pobierać TimeToReachQueue informacje o właściwości podczas odbierania lub podglądu komunikatu.

TransactionId

Pobiera lub ustawia wartość wskazującą, czy pobierać TransactionId informacje o właściwości podczas odbierania lub podglądu komunikatu.

TransactionStatusQueue

Pobiera lub ustawia wartość wskazującą, czy pobierać TransactionStatusQueue informacje o właściwości podczas odbierania lub podglądu komunikatu.

UseAuthentication

Pobiera lub ustawia wartość wskazującą, czy pobierać UseAuthentication informacje o właściwości podczas odbierania lub przeglądania komunikatu.

UseDeadLetterQueue

Pobiera lub ustawia wartość wskazującą, czy pobierać UseDeadLetterQueue informacje o właściwości podczas odbierania lub przeglądania komunikatu.

UseEncryption

Pobiera lub ustawia wartość wskazującą, czy pobierać UseEncryption informacje o właściwości podczas odbierania lub przeglądania komunikatu.

UseJournalQueue

Pobiera lub ustawia wartość wskazującą, czy pobierać UseJournalQueue informacje o właściwości podczas odbierania lub przeglądania komunikatu.

UseTracing

Pobiera lub ustawia wartość wskazującą, czy pobierać UseTracing informacje o właściwości podczas odbierania lub przeglądania komunikatu.

Metody

ClearAll()

Ustawia wszystkie wartości filtru logicznego na falsewartość , aby podczas odbierania komunikatu nie pobrano żadnych właściwości komunikatów.

Clone()

Tworzy płytkią kopię obiektu.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
SetAll()

Określa, aby pobrać wszystkie właściwości komunikatu podczas odbierania komunikatu.

SetDefaults()

Ustawia wartości filtru typowych właściwości kolejkowania komunikatów na true i właściwości liczb całkowitych wartości domyślnych.

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też