This topic has not yet been rated - Rate this topic

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.

  Name Description
Public method DefaultPropertiesToSend Initializes a new instance of the DefaultPropertiesToSend class.
Top
  Name Description
Public property AcknowledgeType Gets or sets the type of acknowledgement message to be returned to the sending application.
Public property AdministrationQueue Gets or sets the queue that receives acknowledgement messages generated by Message Queuing.
Public property AppSpecific Gets or sets additional, application-specific information.
Public property AttachSenderId Gets or sets a value that indicates whether the sender ID should be attached to the message.
Public property EncryptionAlgorithm Gets or sets the encryption algorithm used to encrypt the body of a private message.
Public property Extension Gets or sets additional information associated with the message.
Public property HashAlgorithm Gets or sets the hashing algorithm used when authenticating messages or creating a digital signature for a message.
Public property Label Gets or sets an application-defined string that describes the message.
Public property Priority Gets or sets the message priority, which is used to determine where the message is placed in the queue.
Public property Recoverable Gets 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 property ResponseQueue Gets or sets the queue that receives application-generated response messages.
Public property TimeToBeReceived Gets or sets the time limit for the message to be retrieved from the destination queue.
Public property TimeToReachQueue Gets or sets the time limit for the message to reach the queue.
Public property TransactionStatusQueue Gets the transaction status queue on the source computer.
Public property UseAuthentication Gets or sets a value that indicates whether the message must be authenticated before being sent.
Public property UseDeadLetterQueue Gets 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 property UseEncryption Gets or sets a value that indicates whether to make the message private.
Public property UseJournalQueue Gets or sets a value that indicates whether a copy of the message should be kept in a machine journal on the originating computer.
Public property UseTracing Gets or sets a value that indicates whether to trace a message as it moves toward its destination queue.
Top
  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns 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, 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)
Community Content Add
Annotations FAQ