NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DefaultPropertiesToSend Class

Specifies the default property values that will be used when sending objects using the message queue.

Object
   DefaultPropertiesToSend

[Visual Basic]
Public Class DefaultPropertiesToSend
[C#]
public class DefaultPropertiesToSend
[C++]
public __gc class DefaultPropertiesToSend
[JScript]
public class DefaultPropertiesToSend

Remarks

You can set default properties that will be used to set selected default values for new messages created by the MessageQueue class. Properties that you do not set explicitly default to the values specified by the constructor, DefaultPropertiesToSend.

All properties in DefaultPropertiesToSend correspond to identically named properties in the Message class. When you modify the default properties for a message queue, you are defining the default property values for outgoing messages associated with that queue.

The property members of DefaultPropertiesToSend provide access to the properties in the Message Queuing application's MSMQMessage object. The following table shows the DefaultPropertiesToSend properties and the corresponding MSMQMessage properties.

DefaultPropertiesToSend Property MSMQMessage Property
AcknowledgeType Ack
AdministrationQueue AdminQueueInfo
AppSpecific AppSpecific
AttachSenderId SenderIdType
EncryptionAlgorithm EncryptionAlgorithm
Extension Extension
HashAlgorithm HashAlgorithm
Label Label
Priority Priority
Recoverable Delivery
ResponseQueue ResponseQueueInfo
TimeToBeReceived MaxTimeToReceive
TimeToReachQueue MaxTimeToReachQueue
TransactionStatusQueue TransactionStatusQueueInfo
UseAuthentication IsAuthenticated
UseDeadLetterQueue Journal
UseEncryption PrivLevel
UseJournalQueue Journal
UseTracing Trace

For more information about the MSMQMessage object, see the TBD topic in the Platform SDK.

When you create an instance of DefaultPropertiesToSend, the read/write properties are set to initial values. For a list of these values, see the DefaultPropertiesToSend constructor.

Requirements

Namespace: System.Messaging

Assembly: system.messaging.dll

Example [Visual Basic]

The following example demonstrates defining different DefaultPropertiesToSend based on whether a message passed into the procedure has highest or normal MessagePriority. The properties that are set, which apply to the message to be sent to the message queue, are the Label, the Priority, the TimeToBeReceived, and the TimeToReachQueue. It is important to note that these properties are set through the TBD, but they apply to the Message object.

This example assumes that the calling procedure passes in a MessagePriority, and that an urgent message is indicated by Highest priority. It also assumes that the calling method defines the Message that is to be sent to the queue.

[Visual Basic]

Private Sub SetDefaultPropertiesToSend(ByVal urgency As MessagePriority, ByVal msg As System.Messaging.Message)
    'Create DefaultPropertiesToSend objects
    Dim urgentMessageProperties As DefaultPropertiesToSend
    Dim normalMessageProperties As DefaultPropertiesToSend
    'Define and instantiate a new MessageQueue object
    Dim MessageQueue1 As System.Messaging.MessageQueue.MessageQueue
    Set Me.MessageQueue1 = New System.Messaging.MessageQueue
    'Set the queue formatter to the XML-based formatter
    Set MessageQueue1.Formatter = New System.Messaging.XmlQueueMessageFormatter
    Set MessageQueue1.DefaultPropertiesToSend.UseDeadLetterQueue = True       
 
    'Set the label for the queue (as opposed to the message labels).
    Set MessageQueue1.Label = "Order Queue"
    'Set the queue path
    MessageQueue1.Path = "mycomputer\myqueue"
    'Instantiate two new DefaultPropertiesToSend objects
    Set urgentMessageProperties = New DefaultPropertiesToSend
    Set normalMessageProperties = New DefaultPropertiesToSend
    'Set the label and priority for urgent messages
    urgentMessageProperties.Label = "Urgent Message"
    urgentMessageProperties.Priority = MessagePriority.Highest
    'Make the process wait indefinitely for a message.
    urgentMessageProperties.TimeToBeReceived = Message.InfiniteTimeout
    urgentMessageProperties.TimeToReachQueue = Message.InfiniteTimeout
    urgentMessageProperties.UseDeadLetterQueue = True
    'set the label and priority for normal messages
    normalMessageProperties.Label = "Normal Message"
    normalMessageProperties.Priority = MessagePriority.Normal
    'Make the process wait a finite amount of time for a message.
    normalMessageProperties.TimeToBeReceived = 3000
    normalMessageProperties.TimeToReachQueue = 3000
    normalMessageProperties.UseDeadLetterQueue = True
    'If the message is urgent, use the urgent DefaultPropertiesToSend
    If urgency = MessagePriority.Highest Then
        Set MessageQueue1.DefaultPropertiesToSend = urgentMessageProperties
    Else
        'Otherwise, use normal DefaultPropertiesToSend
        Set MessageQueue1.DefaultPropertiesToSend = normalMessageProperties
    End If
    'Override default properties on the message object
    msg.Priority = MessageQueue1.DefaultPropertiesToSend.Priority
    msg.Label = MessageQueue1.DefaultPropertiesToSend.Label
    msg.TimeToBeReceived = MessageQueue1.DefaultPropertiesToSend.TimeToBeReceived
    msg.TimeToReachQueue = MessageQueue1.DefaultPropertiesToSend.TimeToReachQueue
    'Send the message that was passed in.
    MessageQueue1.Send msg
    'Display Label and MessagePriority information on the screen
    MessageBox.Show MessageQueue1.DefaultPropertiesToSend.Label & ". Priority: " & MessageQueue1.DefaultPropertiesToSend.Priority
End Sub

See Also

DefaultPropertiesToSend Members | System.Messaging Namespace | Message | TBD