HOWTO: Filter Messages with Specific Property Values?

ID: Q176016


The information in this article applies to:
  • Microsoft Message Queue Server version 1.0


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.


REFERENCES

For more information or to see a code example to find a specific message using cursors, search the "Reading Messages Using a Cursor" topic in the MSMQ SDK help file.

(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Syed Yousuf, Microsoft Corporation

Additional query words: filter sort

Keywords : MQProg
Version : winnt:1.0
Platform : winnt
Issue type : kbinfo


Last Reviewed: August 30, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.