Share via


Opening a Queue to Read Messages (COM) (Windows Embedded CE 6.0)

1/6/2010

When opening a queue to read messages, the receiving application must specify how the messages are read from the queue and who else can access the queue when it is open.

The queue's access mode can be set to MQ_PEEK_ACCESS or MQ_RECEIVE_ACCESS. Use MQ_PEEK_ACCESS when you want to peek at messages without removing them. Use MQ_RECEIVE_ACCESS when you want to peek or retrieve the messages in the queue.

The queue's share mode can be set to MQ_DENY_NONE or MQ_DENY_SHARE_RECEIVE. When peeking at the messages in the queue, MQ_DENY_NONE must be specified. When retrieving messages, either setting can be used.

Both these modes are set when calling MSMQQueueInfo.Open.

Note

Before opening a queue, Message Queuing verifies that the access mode requested by the application does not conflict with the access rights of the queue. If MQ_ERROR_ACCESS_DENIED is returned to the Open call, the queue's access control is blocking the application from opening the queue.

To open a queue to read messages

  1. Declare a MSMQQueueInfo and MSMQQueue object.

  2. Obtain a MSMQQueueInfo object.

    The C++ COM code example tries to create a new MSMQQueueInfo object, ignoring any errors if a queue with the same pathname already exists. QueueInfo objects for public queues can also be obtained from doing a query on the directory service.

  3. Call MSMQQueueInfo.Open to open the queue with receive or peek access.

    The following examples open the queue with receive access and deny none share mode.

  4. (Optional) Add code for retrieving messages from the queue.

  5. Call MSMQQueue.Close to close the queue.

For a code example using C++ COM, see C++ COM Code Example: Opening a Queue to Read Messages.

See Also

Concepts

Opening a Queue (COM)
MSMQ COM Support
Using the COM Components
MSMQ Security

Other Resources

Message Queuing