Partager via


MSMQQueue.PeekNext (Windows Embedded CE 6.0)

1/6/2010

This method looks at the next message after the current cursor position, but does not remove the message from the queue.

When PeekNext is called, execution is stopped until the message is read from the queue or the receive time-out timer, ReceiveTimeout, expires.

Syntax

HRESULT PeekNext( 
  VARIANT* WantDestinationQueue, 
  VARIANT* WantBody, 
  VARIANT* ReceiveTimeout, 
  MSMQMessage** ppmsg 
);

Parameters

  • WantDestinationQueue
    Optional. The default is FALSE.

    If TRUE, MSMQMessage.DestinationQueueInfo is updated when the message is read from the queue. Setting this property to TRUE can slow the operation of the application.

  • WantBody
    Optional. The default is TRUE.

    If the Body of the message is not needed, set this property to FALSE to optimize the speed of the application.

  • ReceiveTimeout
    Optional. Specifies how long, in milliseconds, Message Queuing waits for a message to arrive when the cursor is pointing at the end of the queue.
  • ppmsg
    Next message.

Return Value

The following table describes the common return values.

Value Description

S_OK

Success

E_INVALIDARG

One or more arguments are invalid

E_NOTIMPL

The function contains no implementation

E_OUTOFMEMORY

Out of memory

Remarks

MSMQQueue.PeekNext uses the cursor created when the queue is opened to locate the message. (Do not use this method when navigating the queue using lookup identifiers.)

This method is typically used with MSMQQueue.PeekCurrent and MSMQQueue.ReceiveCurrent when navigating through the queue.

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

Ee498414.collapse(en-US,WinEmbedded.60).gifBefore calling MSMQQueue.PeekNext

The MSMQQueue.PeekCurrent method must be called to point the cursor to the first message in the queue.

If MSMQQueue.PeekNext is called before MSMQQueue.PeekCurrent, MQ_ERROR_ILLEGAL CURSOR_ACTION is returned.

Ee498414.collapse(en-US,WinEmbedded.60).gifReceiveTimeout parameter

Optional. If a timeout period is specified and a timeout occurs, a Null message object is returned to the application.

If a timeout period is not specified, the default value of ReceiveTimeout (INFINITE) forces the MSMQQueue.PeekCurrent call to block execution until a message arrives.

Ee498414.collapse(en-US,WinEmbedded.60).gifWantDestinationQueue and WantBody parameters

Use the WantDestinationQueue and WantBody parameters to optimize the speed of the application.

Ee498414.collapse(en-US,WinEmbedded.60).gifMessage body type

When peeking at message, you cannot look at the type of message body included in the message. Message Queuing determines the body type based on the message's body type property. (The body type property of the messages can be accessed only with Message Queuing functions.)

If the message was sent using MQSendMessage, the following situations can occur.

  • If the body type property was not set before MQSendMessage is called, the message body is treated as an array of bytes.
  • If the body type was set to an invalid body type before MQSendMessage is called, the message can be retrieved, but an error occurs when you try to read the message body.

Ee498414.collapse(en-US,WinEmbedded.60).gifPeeking at Messages Asynchronously

The MSMQEvent object, used to read messages asynchronously, is implemented in terms of callbacks, and is limited to 64 callbacks per process.

Internally, Message Queuing uses the WaitForMultipleObjects function, which is limited to 64 objects per process.

Ee498414.collapse(en-US,WinEmbedded.60).gifResponding to Messages

The receiving application can determine if the sending application expects a response messages by retrieving the MSMQMessage.ResponseDestination (introduced in MSMQ 3.0) or MSMQMessage.ResponseQueueInfo property when reading the message.

If the property is set to Null, the sending application is not expecting a response message.

Ee498414.collapse(en-US,WinEmbedded.60).gifOpening queues

Applications can peek at messages in queues opened with peek or receive access (see MSMQQueueInfo.Open).

Opening a queue with peek access requires a direct connection to the computer where the queue resides. You cannot peek at messages in a queue that resides on a computer that has no direct connection to the computer where your application is running.

Ee498414.collapse(en-US,WinEmbedded.60).gifEquivalent Function

When using function calls, use MQReceiveMessage to peek at messages in the queue. To peek at messages using this function, set the dwAction parameter to the appropriate value.

Requirements

Header mqoai.h
Library mqoa.lib
Windows Embedded CE Windows CE .NET 4.0 and later

See Also

Reference

MSMQQueue