共用方式為


MSMQMessage.MaxTimeToReceive

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

The MaxTimeToReceive property of the MSMQMessage object specifies a time limit (in seconds) for the message to be retrieved from the target queue. This includes the time spent getting to the destination queue plus the time spent waiting in the queue before it is retrieved by an application.

Data type: Long
Run-time access: Read/write
Property MaxTimeToReceive As Long  

Property Value

An integer value (the default is INFINITE).

Remarks

MaxTimeToReceive is used to set the message's time-to-be-received timer. If the time-to-be-received interval elapses before the message is removed from the queue, Message Queuing discards the message, sending it to the dead-letter queue if the message's MSMQMessage.Journal property is set to MQMSG_DEADLETTER. For a discussion of message timers, see Message Timers.

Message Queuing can also send a negative acknowledgment message back to the sending application if the message's MSMQMessage.Ack property is set accordingly and the message is not retrieved before the time interval elapses.

In each hop, Message Queuing subtracts the time elapsed on the applicable computer from MaxTimeToReceive when it dispatches the message to the next computer, where a new timer is set. After a message arrives at the destination queue, MaxTimeToReceive can be used to find out how much time remains in the time-to-be-received timer.

Message Queuing uses two message timers: time-to-reach-queue and time-to-be-received. If the time-to-be-received timer is set to a value less than the time-to-reach-queue timer, the time-to-be-received timer takes precedence over the time-to-reach-queue timer.

When several messages are sent in a transaction, Message Queuing automatically uses the time-to-be-received timer of the first message. For more information, see Transactions.

When Message Queuing creates an acknowledgment message, it always sets the message's MaxTimeToReceive property to INFINITE.

When a message is sent from an independent client computer, the time-to-be-received timer starts ticking as soon as the send operation of the sending application succeeds, even if the client computer is offline.

When using dependent clients, make sure that the clock on the client computer is in sync with the clock on its supporting server. If these two clocks are not synchronized, you may see unpredictable behavior when sending messages with a time-to-be-received timer set.

When a message is sent over an HTTP transport, the relative time specified in the MaxTimeToReceive property of the message is converted to the absolute UTC date and time until which the message may be stored in the destination queue and is inserted into the <TTrq> element in the header portion of the SOAP envelope. For more information on the <TTrq> element of an HTTP message, see Properties Mapped to Elements of the MSMQ Namespace.

Equivalent API Function Property

With API function calls, the equivalent property is PROPID_M_TIME_TO_BE_RECEIVED.

Requirements

Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib.

See Also

MSMQMessage
MSMQMessage.Ack
MSMQMessage.Journal
PROPID_M_TIME_TO_BE_RECEIVED