Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

MessagePropertyFilter Class

Controls and selects the properties that are retrieved when peeking or receiving messages from a message queue.

System.Object
  System.Messaging.MessagePropertyFilter

Namespace:  System.Messaging
Assembly:  System.Messaging (in System.Messaging.dll)
[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
public class MessagePropertyFilter : ICloneable

The MessagePropertyFilter type exposes the following members.

  NameDescription
Public methodMessagePropertyFilterInitializes a new instance of the MessagePropertyFilter class and sets default values for all properties.
Top
  NameDescription
Public propertyAcknowledgeTypeGets or sets a value that indicates whether to retrieve Message.AcknowledgeType property information when receiving or peeking a message.
Public propertyAcknowledgmentGets or sets a value that indicates whether to retrieve Message.Acknowledgment property information when receiving or peeking a message.
Public propertyAdministrationQueueGets or sets a value that indicates whether to retrieve Message.AdministrationQueue property information when receiving or peeking a message.
Public propertyAppSpecificGets or sets a value that indicates whether to retrieve Message.AppSpecific property information when receiving or peeking a message.
Public propertyArrivedTimeGets or sets a value that indicates whether to retrieve Message.ArrivedTime property information when receiving or peeking a message.
Public propertyAttachSenderIdGets or sets a value that indicates whether to retrieve Message.AttachSenderId property information when receiving or peeking a message.
Public propertyAuthenticatedGets or sets a value that indicates whether to retrieve Message.Authenticated property information when receiving or peeking a message.
Public propertyAuthenticationProviderNameGets or sets a value that indicates whether to retrieve Message.AuthenticationProviderName property information when receiving or peeking a message.
Public propertyAuthenticationProviderTypeGets or sets a value that indicates whether to retrieve Message.AuthenticationProviderType property information when receiving or peeking a message.
Public propertyBodyGets or sets a value that indicates whether to retrieve Message.Body property information when receiving or peeking a message.
Public propertyConnectorTypeGets or sets a value that indicates whether to retrieve Message.ConnectorType property information when receiving or peeking a message.
Public propertyCorrelationIdGets or sets a value that indicates whether to retrieve Message.CorrelationId property information when receiving or peeking a message.
Public propertyDefaultBodySizeGets or sets the size, in bytes, of the default body buffer.
Public propertyDefaultExtensionSizeGets or sets the size, in bytes, of the default extension buffer.
Public propertyDefaultLabelSizeGets or sets the size, in bytes, of the default label buffer.
Public propertyDestinationQueueGets or sets a value that indicates whether to retrieve Message.DestinationQueue property information when receiving or peeking a message.
Public propertyDestinationSymmetricKeyGets or sets a value that indicates whether to retrieve Message.DestinationSymmetricKey property information when receiving or peeking a message.
Public propertyDigitalSignatureGets or sets a value that indicates whether to retrieve Message.DigitalSignature property information when receiving or peeking a message.
Public propertyEncryptionAlgorithmGets or sets a value that indicates whether to retrieve Message.EncryptionAlgorithm property information when receiving or peeking a message.
Public propertyExtensionGets or sets a value that indicates whether to retrieve Message.Extension property information when receiving or peeking a message.
Public propertyHashAlgorithmGets or sets a value that indicates whether to retrieve Message.HashAlgorithm property information when receiving or peeking a message.
Public propertyIdGets or sets a value that indicates whether to retrieve Message.Id property information when receiving or peeking a message.
Public propertyIsFirstInTransactionGets or sets a value that indicates whether to retrieve Message.IsFirstInTransaction property information when receiving or peeking a message.
Public propertyIsLastInTransactionGets or sets a value that indicates whether to retrieve Message.IsLastInTransaction property information when receiving or peeking a message.
Public propertyLabelGets or sets a value that indicates whether to retrieve Message.Label property information when receiving or peeking a message.
Public propertyLookupIdGets or sets a value that indicates whether to retrieve LookupId property information when receiving or peeking a message.
Public propertyMessageTypeGets or sets a value that indicates whether to retrieve Message.MessageType property information when receiving or peeking a message.
Public propertyPriorityGets or sets a value that indicates whether to retrieve Message.Priority property information when receiving or peeking a message.
Public propertyRecoverableGets or sets a value that indicates whether to retrieve Message.Recoverable property information when receiving or peeking a message.
Public propertyResponseQueueGets or sets a value that indicates whether to retrieve Message.ResponseQueue property information when receiving or peeking a message.
Public propertySenderCertificateGets or sets a value that indicates whether to retrieve Message.SenderCertificate property information when receiving or peeking a message.
Public propertySenderIdGets or sets a value that indicates whether to retrieve Message.SenderId property information when receiving or peeking a message.
Public propertySenderVersionGets or sets a value that indicates whether to retrieve Message.SenderVersion property information when receiving or peeking a message.
Public propertySentTimeGets or sets a value that indicates whether to retrieve Message.SentTime property information when receiving or peeking a message.
Public propertySourceMachineGets or sets a value that indicates whether to retrieve Message.SourceMachine property information when receiving or peeking a message.
Public propertyTimeToBeReceivedGets or sets a value that indicates whether to retrieve Message.TimeToBeReceived property information when receiving or peeking a message.
Public propertyTimeToReachQueueGets or sets a value that indicates whether to retrieve Message.TimeToReachQueue property information when receiving or peeking a message.
Public propertyTransactionIdGets or sets a value that indicates whether to retrieve Message.TransactionId property information when receiving or peeking a message.
Public propertyTransactionStatusQueueGets or sets a value that indicates whether to retrieve Message.TransactionStatusQueue property information when receiving or peeking a message.
Public propertyUseAuthenticationGets or sets a value that indicates whether to retrieve Message.UseAuthentication property information when receiving or peeking a message.
Public propertyUseDeadLetterQueueGets or sets a value that indicates whether to retrieve Message.UseDeadLetterQueue property information when receiving or peeking a message.
Public propertyUseEncryptionGets or sets a value that indicates whether to retrieve Message.UseEncryption property information when receiving or peeking a message.
Public propertyUseJournalQueueGets or sets a value that indicates whether to retrieve Message.UseJournalQueue property information when receiving or peeking a message.
Public propertyUseTracingGets or sets a value that indicates whether to retrieve Message.UseTracing property information when receiving or peeking a message.
Top
  NameDescription
Public methodClearAllSets all Boolean filter values to false, so that no message properties are retrieved when receiving a message.
Public methodCloneCreates a shallow copy of the object.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSetAllSpecifies to retrieve all message properties when receiving a message.
Public methodSetDefaultsSets the filter values of common Message Queuing properties to true and the integer-valued properties to their default values.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

Setting the MessagePropertyFilter on a MessageQueue instance controls the set of properties that are retrieved when peeking or receiving a message. The filter is set on the instance of MessageQueue that retrieves the message information. When you set a MessagePropertyFilter Boolean-valued member to false, you prevent the information of the associated Message property from being retrieved by the MessageQueue.

There are several filter properties that are not Boolean values. They are integer values that get or set the default sizes of the Message.Body, Message.Extension, or Message.Label.

Retrieving a limited set of properties helps improve performance because smaller amounts of data are transferred from the queue.

When setting a property on MessagePropertyFilter, you are only indicating whether that property is retrieved when a message is received or peeked. You are not changing the associated property value for the Message.

The MessagePropertyFilter constructor sets all filter properties to their default values, which for the Boolean values is false. See the constructor topic for the defaults assigned to the integer-valued properties.

The following code example sends two messages of different priorities to the queue, and retrieves them subsequently.


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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.