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 Constructor

Initializes a new instance of the DefaultPropertiesToSend class.

[Visual Basic]
Public Sub New()
[C#]
public DefaultPropertiesToSend();
[C++]
public: DefaultPropertiesToSend();
[JScript]
public function DefaultPropertiesToSend();

Remarks

When you create an instance of DefaultPropertiesToSend, the following read/write properties are initialized.

Property Initial Value
AcknowledgeType AcknowledgeType.None
AdministrationQueue a null reference (in Visual Basic Nothing)
AppSpecific 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)
TimeToBeReceived Message.InfiniteTimeout
TimeToReachQueue Message.InfiniteTimeout
TransactionStatusQueue a null reference (Nothing)
UseAuthentication false
UseDeadLetterQueue false
UseEncryption false
UseJournalQueue false
UseTracing false

You can change the value for any of these properties through a separate call to the property.

Example [Visual Basic]

The following example demonstrates using the constructor to define 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 Class | DefaultPropertiesToSend Members | System.Messaging Namespace | AcknowledgeType | EncryptionAlgorithm | HashAlgorithm | InfiniteTimeout