Microsoft KB Archive/176016

= How To Filter Messages with Specific Property Values? =

Article ID: 176016

Article Last Modified on 6/30/2004

-

APPLIES TO


 * Microsoft Message Queue Server 1.0

-



This article was previously published under Q176016



SUMMARY
When you retrieve a message that is not at the front of the queue and its properties match with specific values (values for PROPID_M_MSGID, PROPID_M_CORRELATIONID, or any other property), use MQCreateCursor, MQ_ACTION_PEEK_NEXT, and MQ_ACTION_PEEK_CURRENT functionality in MQReceiveMessage.



MORE INFORMATION
When you use Microsoft Message Queue Server 1.0, applications need to perform filtering on their own. Examine the appropriate message properties and decide whether to skip to the next message or not. Note that you usually do not need to rescan the entire queue. By using a cursor, you examine only new messages arriving to the queue. The MQ_ACTION_PEEK_NEXT and MQ_ACTION_PEEK_CURRENT functionality in C API MQReceiveMessage may be used to implement your own filtering logic.

The receive/peek function is designed to always start at the beginning of the queue and then allow a cursor to be used to traverse the messages in the queue. You are unable to directly address a specific message by any of its properties. One way to get to the specific message is to specify a cursor and then PEEK_NEXT your way through the messages, retrieving only the specific property as your search criteria (PROPID_M_MSGID or any other property). When you find the message you want, you can perform a full receive/peek CURRENT operation to retrieve other properties of that message.

Retrieving arbitrary properties for a message works for the MSMQ C API only. ActiveX Receive methods let you exclude body and DestinationQueueInfo by specifying WantBody and WantDestinationQueue flags.

