PeekNext
MSMQQueue

The PeekNext method returns the next message in the queue, but does not remove it from the queue.

When PeekNext is called, execution is stopped until the message is read from the queue or the receive timeout timer (ReceiveTimeout) expires.

Syntax

set object2 = object1.PeekNext ([ReceiveTimeout][, WantDestinationQueue][, WantBody])
 
Syntax Element Description
object1 Queue (MSMQQueue) object that represents the queue where the message resides.
object2 Message (MSMQMessage) object that represents message read from the queue.
ReceiveTimeout Optional. Specifies how long (in milliseconds) MSMQ waits for a message to arrive when the cursor is pointing at the end of the queue.
WantDestinationQueue Optional (default is FALSE). If TRUE, DestinationQueueInfo is updated when the message is read from the queue. Setting this property to TRUE may slow down the operation of the application.
WantBody Optional (default is TRUE). If the Body of the message is not needed, set this property to FALSE to optimize the speed of the application.

Return Values

MSMQMessage object.

Remarks

PeekNext moves the cursor first, then looks at the message at the new location.

Before PeekNext is called, Peek Current must be called to initialize the implied cursor. If PeekCurrent is not called, MQ_ERROR_ILLEGAL CURSOR_ACTION is returned.

The WantDestinationQueue and WantBody parameters can be used to optimize the speed of the application.

The queue where the message resides can be opened with PEEK or RECEIVE access.


© 1997 by Microsoft Corporation. All rights reserved.