Export (0) Print
Expand All

DefaultPropertiesToSend Class

Specifies the default property values that will be used when sending objects other than Message instances to a message queue.

System.Object
  System.Messaging.DefaultPropertiesToSend

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

[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
public class DefaultPropertiesToSend

The DefaultPropertiesToSend type exposes the following members.

  NameDescription
Public methodDefaultPropertiesToSendInitializes a new instance of the DefaultPropertiesToSend class.
Top

  NameDescription
Public propertyAcknowledgeTypeGets or sets the type of acknowledgement message to be returned to the sending application.
Public propertyAdministrationQueueGets or sets the queue that receives acknowledgement messages generated by Message Queuing.
Public propertyAppSpecificGets or sets additional, application-specific information.
Public propertyAttachSenderIdGets or sets a value that indicates whether the sender ID should be attached to the message.
Public propertyEncryptionAlgorithmGets or sets the encryption algorithm used to encrypt the body of a private message.
Public propertyExtensionGets or sets additional information associated with the message.
Public propertyHashAlgorithmGets or sets the hashing algorithm used when authenticating messages or creating a digital signature for a message.
Public propertyLabelGets or sets an application-defined string that describes the message.
Public propertyPriorityGets or sets the message priority, which is used to determine where the message is placed in the queue.
Public propertyRecoverableGets or sets a value that indicates whether the message is guaranteed to be delivered in the event of a computer failure or network problem.
Public propertyResponseQueueGets or sets the queue that receives application-generated response messages.
Public propertyTimeToBeReceivedGets or sets the time limit for the message to be retrieved from the destination queue.
Public propertyTimeToReachQueueGets or sets the time limit for the message to reach the queue.
Public propertyTransactionStatusQueueGets the transaction status queue on the source computer.
Public propertyUseAuthenticationGets or sets a value that indicates whether the message must be authenticated before being sent.
Public propertyUseDeadLetterQueueGets or sets a value that indicates whether a copy of the message that could not be delivered should be sent to a dead-letter queue.
Public propertyUseEncryptionGets or sets a value that indicates whether to make the message private.
Public propertyUseJournalQueueGets or sets a value that indicates whether a copy of the message should be kept in a machine journal on the originating computer.
Public propertyUseTracingGets or sets a value that indicates whether to trace a message as it moves toward its destination queue.
Top

  NameDescription
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 the default hash function. (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 methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

You can set default values on selected properties for messages sent to a MessageQueue. DefaultPropertiesToSend is used to specify default property values of the message being sent when objects other than Message instances are sent to a queue, for example, the string argument passed into the Send method in the code fragment, myMessageQueue.Send("hello"). The Message class has corresponding, identically named properties to those in DefaultPropertiesToSend that provide the values when sending a Message instance specifically. Even if you have specified MessageQueue.DefaultPropertiesToSend for a queue, sending a Message object to that queue will cause the values for the identically named Message properties to override the queue's DefaultPropertiesToSend values.

Properties that you do not set explicitly default to the values specified by the constructor, DefaultPropertiesToSend.

For a list of initial property values for an instance of DefaultPropertiesToSend, see the DefaultPropertiesToSend constructor.

The following code example uses the priority of a message to determine default properties to send for the message.

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 specifies different types of default 
		// properties for messages. 
		//************************************************** 

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

			// Send normal and high priority messages.
			myNewQueue.SendNormalPriorityMessages();
			myNewQueue.SendHighPriorityMessages();
						
			return;
		}


		//************************************************** 
		// Associates selected message property values 
		// with high priority messages. 
		//************************************************** 
		
		public void SendHighPriorityMessages()
		{

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

			// Associate selected default property values with high 
			// priority messages.
			myQueue.DefaultPropertiesToSend.Priority = 
				MessagePriority.High;
			myQueue.DefaultPropertiesToSend.Label = 
				"High Priority Message";
			myQueue.DefaultPropertiesToSend.Recoverable = true;
			myQueue.DefaultPropertiesToSend.TimeToReachQueue =
				new TimeSpan(0,0,30);
			
			// Send messages using these defaults.
			myQueue.Send("High priority message data 1.");
			myQueue.Send("High priority message data 2.");
			myQueue.Send("High priority message data 3.");
			
			return;
		}


		//************************************************** 
		// Associates selected message property values 
		// with normal priority messages. 
		//************************************************** 
		
		public void SendNormalPriorityMessages()
		{

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

			// Associate selected default property values with normal 
			// priority messages.
			myQueue.DefaultPropertiesToSend.Priority = 
				MessagePriority.Normal;
			myQueue.DefaultPropertiesToSend.Label = 
				"Normal Priority Message";
			myQueue.DefaultPropertiesToSend.Recoverable = false;
			myQueue.DefaultPropertiesToSend.TimeToReachQueue =
				new TimeSpan(0,2,0);
			
			// Send messages using these defaults.
			myQueue.Send("Normal priority message data 1.");
			myQueue.Send("Normal priority message data 2.");
			myQueue.Send("Normal priority message data 3.");
			
			return;
		}
	}
}

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft