Opening Remote Queues with Peek or Receive Access

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

When you open a remote queue to peek at or retrieve messages, both computers, as part of the process, contact the directory service and contact each other, as shown in the following illustration.

Description

When your application makes its call to open the remote queue with peek or receive access, the following actions are taken:

  • The MSMQ runtime contacts the local queue manager, sending a request to open the queue.

  • The local queue manager determines if the queue is public or private.

  • If the queue is public and it is referenced by a public format name, the queue manager contacts the directory service to get the registered properties of the queue. It then checks to see if the queue is local or remote. When the queue manager determines that the queue is remote, it returns the name of the remote computer to the local runtime.

  • If, on the other hand, the queue is private, the queue manager looks at the queue identifier (GUID) included in the format name to see if the queue is local or remote. When the queue manager determines that the queue is remote, it queries the directory service to convert the computer GUID to a computer name and returns the name of the remote computer to the local runtime, just as for a public queue.

  • The local runtime then contacts the remote queue manager in an RPC call to open the queue.

  • The remote queue manager then begins the process of creating the queue object.

If the queue is public, the queue manager contacts the directory service, in several separate calls to get the properties and to get the security descriptor of the queue.

If the queue is private, it gets the properties and security descriptor of the queue from the local LQS file.

  • Using the properties and security descriptor of the queue, the remote queue manager checks the access rights of the queue, and if the caller is allowed to open the queue with the access requested, the queue manager creates a queue object and returns it to the runtime on the local computer.

  • The local runtime then contacts the local queue manager, passing on the queue handle from the remote queue manager.

  • The local queue manager then makes a proxy object that represents the remote queue object, opens a virtual session with the remote queue manager (using an RPC context handle), and returns a handle to the proxy object that it created.

  • The local runtime then passes the handle to the proxy object on to the calling application.

Note

When you open a remote queue for peek or receive access, MSMQ can return an MQ_ERROR_QUEUE_NOT_FOUND error message from one of two sources. The error message can be returned by the local queue manager or by the remote queue manager.

If the connection between the local computer (the RPC client) and the remote computer (the RPC server) breaks during a call to read or peek at a message, the client RPC service waits two hours (by default) before failing the call. At the same time, Message Queuing cancels the RPC session and fails the call after five minutes (by default) or, if the calling function or method has a time-out parameter, after a time interval equal to the sum of five minutes (by default) and the time specified in the time-out parameter. The default value of five minutes for the waiting period before canceling RPC calls made by Message Queuing can be adjusted by setting the following registry entry:

HKLM\SOFTWARE\Microsoft\MSMQ\Parameters\RPCCancelTimeout  

In MSMQ 2.0 and MSMQ 3.0, you must add this entry to change the default value.

More Information

For information on See
How MSMQ opens remote queues to send messages. Opening Remote Queues with Send Access
How MSMQ opens local queues. Opening Local Queues
What is required to open a queue. Opening Queues