MessageReadPropertyFilter Property
.NET Framework Class Library
MessageQueue.MessageReadPropertyFilter Property

Gets or sets the property filter for receiving or peeking messages.

Namespace: System.Messaging
Assembly: System.Messaging (in system.messaging.dll)

Visual Basic (Declaration)
Public Property MessageReadPropertyFilter As MessagePropertyFilter
Visual Basic (Usage)
Dim instance As MessageQueue
Dim value As MessagePropertyFilter

value = instance.MessageReadPropertyFilter

instance.MessageReadPropertyFilter = value
C#
public MessagePropertyFilter MessageReadPropertyFilter { get; set; }
C++
public:
property MessagePropertyFilter^ MessageReadPropertyFilter {
    MessagePropertyFilter^ get ();
    void set (MessagePropertyFilter^ value);
}
J#
/** @property */
public MessagePropertyFilter get_MessageReadPropertyFilter ()

/** @property */
public void set_MessageReadPropertyFilter (MessagePropertyFilter value)
JScript
public function get MessageReadPropertyFilter () : MessagePropertyFilter

public function set MessageReadPropertyFilter (value : MessagePropertyFilter)

Property Value

The MessagePropertyFilter used by the queue to filter the set of properties it receives or peeks for each message.
Exception typeCondition

ArgumentException

The filter is a null reference (Nothing in Visual Basic).

This filter is a set of Boolean values restricting the message properties that the MessageQueue receives or peeks. When the MessageQueue receives or peeks a message from the server queue, it retrieves only those properties for which the MessageReadPropertyFilter value is true.

The following shows initial property values for the MessageReadPropertyFilter property. These settings are identical to calling SetDefaults on a MessagePropertyFilter.

The following table shows whether this property is available in various Workgroup modes.

Workgroup mode

Available

Local computer

Yes

Local computer and direct format name

Yes

Remote computer

Yes

Remote computer and direct format name

Yes

The following code example uses the MessageReadPropertyFilter to restrict the message properties received.

Visual Basic
Imports System
Imports System.Messaging

Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '         
        ' This example retrieves specific groups of Message
        ' properties.
        

        Public Shared Sub Main()

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

            ' Retrieve specific sets of Message properties.
            myNewQueue.RetrieveDefaultProperties()
            myNewQueue.RetrieveAllProperties()
            myNewQueue.RetrieveSelectedProperties()

            Return

        End Sub 'Main


        
        ' Retrieves the default properties for a Message.
        

        Public Sub RetrieveDefaultProperties()

            ' Connect to a message queue.
            Dim myQueue As New MessageQueue(".\myQueue")

            ' Specify to retrieve the default properties only.
            myQueue.MessageReadPropertyFilter.SetDefaults()

            ' Set the formatter for the Message.
            myQueue.Formatter = New XmlMessageFormatter(New Type() _
                {GetType([String])})

            ' Receive the first message in the queue.
            Dim myMessage As Message = myQueue.Receive()

            ' Display selected properties.
            Console.WriteLine(("Label: " + myMessage.Label))
            Console.WriteLine(("Body: " + CType(myMessage.Body, _
                [String])))

            Return

        End Sub 'RetrieveDefaultProperties


        
        ' Retrieves all properties for a Message.
        

        Public Sub RetrieveAllProperties()

            ' Connect to a message queue.
            Dim myQueue As New MessageQueue(".\myQueue")

            ' Specify to retrieve all properties.
            myQueue.MessageReadPropertyFilter.SetAll()

            ' Set the formatter for the Message.
            myQueue.Formatter = New XmlMessageFormatter(New Type() _
                {GetType([String])})

            ' Receive the first message in the queue.
            Dim myMessage As Message = myQueue.Receive()

            ' Display selected properties.
            Console.WriteLine(("Encryption algorithm: " + _
                myMessage.EncryptionAlgorithm.ToString()))
            Console.WriteLine(("Body: " + CType(myMessage.Body, _
                [String])))

            Return

        End Sub 'RetrieveAllProperties


        
        ' Retrieves application-specific properties for a
        ' Message.
        

        Public Sub RetrieveSelectedProperties()

            ' Connect to a message queue.
            Dim myQueue As New MessageQueue(".\myQueue")

            ' Specify to retrieve selected properties.
            Dim myFilter As New MessagePropertyFilter()
            myFilter.ClearAll()
            ' The following list is a random subset of properties.
            myFilter.Body = True
            myFilter.Label = True
            myFilter.MessageType = True
            myFilter.Priority = True
            myQueue.MessageReadPropertyFilter = myFilter

            ' Set the formatter for the Message.
            myQueue.Formatter = New XmlMessageFormatter(New Type() _
                {GetType([String])})

            ' Receive the first message in the queue.
            Dim myMessage As Message = myQueue.Receive()

            ' Display selected properties.
            Console.WriteLine(("Message type: " + _
                myMessage.MessageType.ToString()))
            Console.WriteLine(("Priority: " + _
                myMessage.Priority.ToString()))

            Return

        End Sub 'RetrieveSelectedProperties

End Class 'MyNewQueue
C#
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 retrieves specific groups of Message
        // properties.
        /***************************************************/

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

            // Retrieve specific sets of Message properties.
            myNewQueue.RetrieveDefaultProperties();
            myNewQueue.RetrieveAllProperties();
            myNewQueue.RetrieveSelectedProperties();

            return;
        }


        /***************************************************/
        // Retrieves the default properties for a Message.
        /***************************************************/
        
        public void RetrieveDefaultProperties()
        {

            // Connect to a message queue.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            // Specify to retrieve the default properties only.
            myQueue.MessageReadPropertyFilter.SetDefaults();

            // Set the formatter for the Message.
            myQueue.Formatter = new XmlMessageFormatter(new Type[]
                {typeof(String)});

            // Receive the first message in the queue.
            Message myMessage = myQueue.Receive();

            // Display selected properties.
            Console.WriteLine("Label: " + myMessage.Label);
            Console.WriteLine("Body: " + (String)myMessage.Body);
    
            return;
        }


        /***************************************************/
        // Retrieves all properties for a Message.
        /***************************************************/
        
        public void RetrieveAllProperties()
        {

            // Connect to a message queue.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            // Specify to retrieve all properties.
            myQueue.MessageReadPropertyFilter.SetAll();

            // Set the formatter for the Message.
            myQueue.Formatter = new XmlMessageFormatter(new Type[]
                {typeof(String)});

            // Receive the first message in the queue.
            Message myMessage = myQueue.Receive();

            // Display selected properties.
            Console.WriteLine("Encryption algorithm: " + 
                myMessage.EncryptionAlgorithm.ToString());
            Console.WriteLine("Body: " + (String)myMessage.Body);
    
            return;
        }
            

        /***************************************************/
        // Retrieves application-specific properties for a
        // Message.
        /***************************************************/
        
        public void RetrieveSelectedProperties()
        {
            // Connect to a message queue.
            MessageQueue myQueue = new MessageQueue(".\\myQueue");

            // Specify to retrieve selected properties.
            MessagePropertyFilter myFilter = new 
                MessagePropertyFilter();
            myFilter.ClearAll();
            // The following list is a random subset of available properties.
            myFilter.Body = true;
            myFilter.Label = true;
            myFilter.MessageType = true;
            myFilter.Priority = true;
            myQueue.MessageReadPropertyFilter = myFilter;

            // Set the formatter for the Message.
            myQueue.Formatter = new XmlMessageFormatter(new Type[]
                {typeof(String)});

            // Receive the first message in the queue.
            Message myMessage = myQueue.Receive();

            // Display selected properties.
            Console.WriteLine("Message type: " + 
                myMessage.MessageType.ToString());
            Console.WriteLine("Priority: " + 
                myMessage.Priority.ToString());
    
            return;
            }
    }
}
C++
#using <system.dll>
#using <system.messaging.dll>

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

   /**************************************************/
   // Retrieves the default properties for a Message.
   /**************************************************/
   void RetrieveDefaultProperties()
   {
      // Connect to a message queue.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

      // Specify to retrieve the default properties only.
      myQueue->MessageReadPropertyFilter->SetDefaults();

      // Set the formatter for the Message.
      array<Type^>^p = gcnew array<Type^>(1);
      p[ 0 ] = String::typeid;
      myQueue->Formatter = gcnew XmlMessageFormatter( p );

      // Receive the first message in the queue.
      Message^ myMessage = myQueue->Receive();

      // Display selected properties.
      Console::WriteLine( "Label: {0}", myMessage->Label );
      Console::WriteLine( "Body: {0}", static_cast<String^>(myMessage->Body) );
      return;
   }


   /**************************************************/
   // Retrieves all properties for a Message.
   /**************************************************/
   void RetrieveAllProperties()
   {
      // Connect to a message queue.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

      // Specify to retrieve all properties.
      myQueue->MessageReadPropertyFilter->SetAll();

      // Set the formatter for the Message.
      array<Type^>^p = gcnew array<Type^>(1);
      p[ 0 ] = String::typeid;
      myQueue->Formatter = gcnew XmlMessageFormatter( p );

      // Receive the first message in the queue.
      Message^ myMessage = myQueue->Receive();

      // Display selected properties.
      Console::WriteLine( "Encryption algorithm: {0}", myMessage->EncryptionAlgorithm.ToString() );
      Console::WriteLine( "Body: {0}", myMessage->Body );
      return;
   }

   /**************************************************/
   // Retrieves application-specific properties for a
   // Message.
   /**************************************************/
   void RetrieveSelectedProperties()
   {
      // Connect to a message queue.
      MessageQueue^ myQueue = gcnew MessageQueue( ".\\myQueue" );

      // Specify to retrieve selected properties.
      MessagePropertyFilter^ myFilter = gcnew MessagePropertyFilter;
      myFilter->ClearAll();

      // The following list is a random subset of available properties.
      myFilter->Body = true;
      myFilter->Label = true;
      myFilter->MessageType = true;
      myFilter->Priority = true;
      myQueue->MessageReadPropertyFilter = myFilter;

      // Set the formatter for the Message.
      array<Type^>^p = gcnew array<Type^>(1);
      p[ 0 ] = String::typeid;
      myQueue->Formatter = gcnew XmlMessageFormatter( p );

      // Receive the first message in the queue.
      Message^ myMessage = myQueue->Receive();

      // Display selected properties.
      Console::WriteLine( "Message type: {0}", myMessage->MessageType.ToString() );
      Console::WriteLine( "Priority: {0}", myMessage->Priority.ToString() );
      return;
   }
};


/**************************************************/
// Provides an entry point into the application.
//         
// This example retrieves specific groups of Message
// properties.
/**************************************************/
int main()
{
   // Create a new instance of the class.
   MyNewQueue^ myNewQueue = gcnew MyNewQueue;

   // Retrieve specific sets of Message properties.
   myNewQueue->RetrieveDefaultProperties();
   myNewQueue->RetrieveAllProperties();
   myNewQueue->RetrieveSelectedProperties();
   return 0;
}
J#
package MyProject;

import System.*;
import System.Messaging.*;

/// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{
    /***************************************************/
    // Provides an entry point into the application.
    //         
    // This example retrieves specific groups of Message
    // properties.
    /***************************************************/
    public static void main(String[] args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();
        // Retrieve specific sets of Message properties.
        myNewQueue.RetrieveDefaultProperties();
        myNewQueue.RetrieveAllProperties();
        myNewQueue.RetrieveSelectedProperties();

        return;
    } //main

    /***************************************************/
    // Retrieves the default properties for a Message.
    /***************************************************/
    public void RetrieveDefaultProperties()
    {
        // Connect to a message queue.
        MessageQueue myQueue = new MessageQueue(".\\myQueue");
        // Specify to retrieve the default properties only.
        myQueue.get_MessageReadPropertyFilter().SetDefaults();
        // Set the formatter for the Message.
        myQueue.set_Formatter(new XmlMessageFormatter(new Type[]
            { String.class.ToType() }));
        // Receive the first message in the queue.
        Message myMessage = myQueue.Receive();
        // Display selected properties.
        Console.WriteLine("Label: " + myMessage.get_Label());
        Console.WriteLine("Body: " + (String)(myMessage.get_Body()));

        return;
    } //RetrieveDefaultProperties

    /***************************************************/
    // Retrieves all properties for a Message.
    /***************************************************/
    public void RetrieveAllProperties()
    {
        // Connect to a message queue.
        MessageQueue myQueue = new MessageQueue(".\\myQueue");
        // Specify to retrieve all properties.
        myQueue.get_MessageReadPropertyFilter().SetAll();
        // Set the formatter for the Message.
        myQueue.set_Formatter(new XmlMessageFormatter(new Type[]
            { String.class.ToType() }));
        // Receive the first message in the queue.
        Message myMessage = myQueue.Receive();
        // Display selected properties.
        Console.WriteLine("Encryption algorithm: "
            + myMessage.get_EncryptionAlgorithm().ToString());
        Console.WriteLine("Body: " + (String)(myMessage.get_Body()));
        return;
    } //RetrieveAllProperties

    /***************************************************/
    // Retrieves application-specific properties for a
    // Message.
    /***************************************************/
    public void RetrieveSelectedProperties()
    {
        // Connect to a message queue.
        MessageQueue myQueue = new MessageQueue(".\\myQueue");
        // Specify to retrieve selected properties.
        MessagePropertyFilter myFilter = new MessagePropertyFilter();
        myFilter.ClearAll();
        // The following list is a random subset of available properties.
        myFilter.set_Body(true);
        myFilter.set_Label(true);
        myFilter.set_MessageType(true);
        myFilter.set_Priority(true);
        myQueue.set_MessageReadPropertyFilter(myFilter);
        // Set the formatter for the Message.
        myQueue.set_Formatter(new XmlMessageFormatter(new Type[] 
            { String.class.ToType() }));
        // Receive the first message in the queue.
        Message myMessage = myQueue.Receive();
        // Display selected properties.
        Console.WriteLine("Message type: "
            + myMessage.get_MessageType().ToString());
        Console.WriteLine("Priority: " + myMessage.get_Priority().ToString());

        return;
    } //RetrieveSelectedProperties
} //MyNewQueue
  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
Page view tracker