MessageQueue::MessageReadPropertyFilter Property

 

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

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

public:
[BrowsableAttribute(false)]
[MessagingDescriptionAttribute("MQ_MessageReadPropertyFilter")]
property MessagePropertyFilter^ MessageReadPropertyFilter {
	MessagePropertyFilter^ get();
	void set(MessagePropertyFilter^ value);
}

Property Value

Type: System.Messaging::MessagePropertyFilter^

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

Exception Condition
ArgumentException

The filter is null.

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.

Property

Default value

Acknowledgment

false

AcknowledgeType

false

AdministrationQueue

true

AppSpecific

false

ArrivedTime

true

AttachSenderId

false

Authenticated

false

AuthenticationProviderName

false

AuthenticationProviderType

false

Body

true

ConnectorType

false

CorrelationId

true

DefaultBodySize

1024 bytes

DefaultExtensionSize

255 bytes

DefaultLabelSize

255 bytes

DestinationQueue

false

DestinationSymmetricKey

false

DigitalSignature

false

EncryptionAlgorithm

false

Extension

false

HashAlgorithm

false

Id

true

IsFirstInTransaction

false

IsLastInTransaction

false

Label

true

MessageType

false

Priority

false

Recoverable

false

ResponseQueue

true

SenderCertificate

false

SenderId

false

SenderVersion

false

SentTime

true

SourceMachine

false

TimeToBeReceived

false

TimeToReachQueue

false

TransactionId

false

TransactionStatusQueue

false

UseAuthentication

false

UseDeadLetterQueue

false

UseEncryption

false

UseJournalQueue

false

UseTracing

false

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.

#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;
}

.NET Framework
Available since 1.1
Return to top
Show: