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!

Message.TimeToReachQueue

Gets or sets the time limit for the message to reach the queue.

[Visual Basic]
Overridable Public Property TimeToReachQueue As TimeSpan
[C#]
public TimeSpan TimeToReachQueue {virtual get; virtual set;}
[C++]
public: __property virtual TimeSpan get_TimeToReachQueue();
public: __property virtual void set_TimeToReachQueue(TimeSpan);
[JScript]
public function get TimeToReachQueue() : TimeSpan;
public function set TimeToReachQueue(TimeSpan);

Property Value

The time limit, in seconds, for the message to reach the queue. The default is InfiniteTimeout.

Exceptions

Exception Type Condition
InvalidOperationException The message queue is filtered not to read the TimeToReachQueue property.
ArgumentException The value specified for TimeToReachQueue is invalid. It may represent a negative number.

Remarks

TimeToReachQueue provides to the MaxTimeToReachQueue property of the Message Queuing MSMQMessage object.

If the TimeToReachQueue interval expires before the message reaches its destination, Message Queuing discards the message and sends 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 does not arrive before the timeout expires

InfiniteTimeout is the only negative integer value that can be used for a timeout. If you attempt to specify any other negative value for TimeToBeReceived or TimeToReachQueue, an ArgumentException exception will be thrown. You should catch this exception in your code when setting the TimeToReachQueue.

Example [Visual Basic]

The following example creates an empty message. The example populates the Message with a string Body, sets the TimeToBeReceived and TimeToReachQueue properties, and then sends the message to a queue. It assumes there is a queue on the computer "myComputer" with the name "myQueue".

Import the System.Messaging namespace for this example.

[Visual Basic]

Private Sub CreateMessage()
    'Declare a message and message queue
    Dim msg As Message
    Dim mq As MessageQueue
    
    'Instantiate an empty message object
    msg = New Message
   
    'Instantiate a new MessageQueue object
    mq = New MessageQueue("myComputer\myQueue")

    'Set selected message properties.
    msg.TimeToBeReceived = New TimeSpan(1000)
    msg.TimeToReachQueue = New TimeSpan(1000)
    msg.Body = "New Message Body"
    'Send the message to the queue.
    mq.Send(msg)
End Sub

See Also

Message Class | Message Members | System.Messaging Namespace | TimeToBeReceived | InfiniteTimeout | UseTracing | Recoverable