Export (0) Print
Expand All

MessageQueue.DefaultPropertiesToSend Property

Gets or sets the message property values to be used by default when the application sends messages to the queue.

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

[MessagingDescriptionAttribute("MQ_DefaultPropertiesToSend")]
[BrowsableAttribute(false)]
public DefaultPropertiesToSend DefaultPropertiesToSend { get; set; }

Property Value

Type: System.Messaging.DefaultPropertiesToSend
A DefaultPropertiesToSend that contains the default Message Queuing message property values used when the application sends objects other than Message instances to the queue.

ExceptionCondition
ArgumentException

The default properties could not be set for the queue, possibly because one of the properties is not valid.

When you send any object that is not of type Message to the queue, the MessageQueue inserts the object into a Message Queuing message. At that time, the MessageQueue applies to the message the property values you specify in the DefaultPropertiesToSend property. Conversely, if you send a Message to the queue, these properties are already specified for the instance itself, so DefaultPropertiesToSend is ignored for the Message.

Although you set the properties through the MessageQueue object, the DefaultPropertiesToSend refers to the properties of the messages that are sent to the queue, not the queue itself.

The default values for the properties are shown in the following table.

Property

Default value

AcknowledgeType

AcknowledgeType.None

AdministrationQueue

null

AppSpecific

Zero (0)

AttachSenderId

true

EncryptionAlgorithm

EncryptionAlgorithm.RC2

Extension

A zero-length array of bytes

HashAlgorithm

HashAlgorithm.MD5

Label

Empty string ("")

Priority

MessagePriority.Normal

Recoverable

false

ResponseQueue

null

TimeToBeReceived

Message.InfiniteTimeout

TimeToReachQueue

Message.InfiniteTimeout

TransactionStatusQueue

null

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 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.5, 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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft