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.TimeToBeReceived

Gets or sets the time limit for the message to be retrieved from the target queue.

[Visual Basic]
Public Property TimeToBeReceived As TimeSpan
[C#]
public TimeSpan TimeToBeReceived {get; set;}
[C++]
public: __property TimeSpan get_TimeToBeReceived();
public: __property void set_TimeToBeReceived(TimeSpan);
[JScript]
public function get TimeToBeReceived() : TimeSpan;
public function set TimeToBeReceived(TimeSpan);

Property Value

The time limit, in seconds, for the message to be retrieved from the target queue. The default is InfiniteTimeout.

Remarks

TimeToBeReceived provides access to the MaxTimeToReceive property of the Message Queuing application's MSMQMessage object.

The time limit for the message to be retrieved from the target queue includes the time spent getting to the destination queue, plus the time spent waiting in the queue before it is retrieved by an application.

If the TimeToBeReceived interval expires before the message is removed from the queue, the Message Queuing application discards the message, sending it to the dead-letter queue if the message's UseDeadLetterQueue property is set to true.

Message Queuing can also send a negative acknowledgment message back to the sending application if the message's AcknowledgeType property is set accordingly and the message is not retrieved before the timer expires.

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 MessageQueue, 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 | TBD