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

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)

public DefaultPropertiesToSend DefaultPropertiesToSend { get; set; }
/** @property */
public DefaultPropertiesToSend get_DefaultPropertiesToSend ()

/** @property */
public void set_DefaultPropertiesToSend (DefaultPropertiesToSend value)

public function get DefaultPropertiesToSend () : DefaultPropertiesToSend

public function set DefaultPropertiesToSend (value : DefaultPropertiesToSend)

Property Value

A DefaultPropertiesToSend that contains the default Message Queuing message property values used when the application sends objects other than Message instances to the queue.
Exception typeCondition

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

a null reference (Nothing in Visual Basic)

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

a null reference (Nothing in Visual Basic)

TimeToBeReceived

Message.InfiniteTimeout

TimeToReachQueue

Message.InfiniteTimeout

TransactionStatusQueue

a null reference (Nothing in Visual Basic)

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

package MyProject;

import System.*;
import System.Messaging.*;

/// <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(String[] args)
    {
        // Create a new instance of the class.
        MyNewQueue myNewQueue = new MyNewQueue();
        // Send normal and high priority messages.
        myNewQueue.SendNormalPriorityMessages();
        myNewQueue.SendHighPriorityMessages();
        return;
    } //main

    //**************************************************
    // 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.get_DefaultPropertiesToSend().
            set_Priority(MessagePriority.High);
        myQueue.get_DefaultPropertiesToSend().
            set_Label("High Priority Message");
        myQueue.get_DefaultPropertiesToSend().
            set_Recoverable(true);
        myQueue.get_DefaultPropertiesToSend().
            set_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;
    } //SendHighPriorityMessages

    //**************************************************
    // 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.get_DefaultPropertiesToSend().
            set_Priority(MessagePriority.Normal);
        myQueue.get_DefaultPropertiesToSend().
            set_Label("Normal Priority Message");
        myQueue.get_DefaultPropertiesToSend().
            set_Recoverable(false);
        myQueue.get_DefaultPropertiesToSend().
            set_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;
    } //SendNormalPriorityMessages
} //MyNewQueue

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.