4.2 Application Opening and Closing a Remote Queue Example
The following sequence diagram illustrates an application interacting with a supporting server to create a queue handle for a queue located at a remote queue manager.
Figure 3: Creating a queue handle
The application invokes the rpc_QMOpenQueueInternal method, providing a format name for a queue to open. NULL is specified for hRemoteQueue.
The supporting server determines that the queue identified by the format name is a remote queue. A path name for the remote queue is returned via lplpRemoteQueueName. All returned handles are NULL.
The application uses the path name returned by the rpc_QMOpenQueueInternal method to determine the computer name of the remote queue manager, as specified in [MS-MQMQ] section 2.1.1. The application then establishes an RPC connection with the remote queue manager and begins the session by invoking the R_QMGetRTQMServerPort method.
The remote queue manager returns the RPC port number requested by the application.
The application invokes the R_QMOpenRemoteQueue method at the remote queue manager, using the RPC port returned by the R_QMGetRTQMServerPort method and specifying the format name of the queue to be opened.
The remote queue manager opens the requested queue and returns a context handle and an OpenQueueDescriptor ADM element instance with its Handle attribute set to the application.
The application invokes the rpc_QMOpenQueueInternal method on the supporting server once again. For this invocation, the client provides the value of the Handle attribute of the OpenQueueDescriptor ADM element instance returned from the R_QMOpenRemoteQueue method.
The supporting server binds to the remote queue manager and utilizes the qm2qm RPC protocol, as defined by [MS-MQQP], to create a remote read session. The client passes the value of the Handle attribute of the OpenQueueDescriptor ADM element instance returned at step 6, which the server uses to correlate the requests.
The qm2qm protocol exchange between the supporting server and the remote queue manager produces a remote read session handle, as specified in [MS-MQQP].
The supporting server internally associates the qm2qm session handle with a new local queue handle and returns the local queue handle to the application.
The application, having successfully acquired a local queue handle, closes the intermediate context handle using the R_QMCloseRemoteQueueContext method.
The application utilizes the local queue handle to execute remote read message operations via the qmcomm2 interface. The supporting server uses the remote read session handle to contact the remote queue manager as necessary to carry out the message operations. This process is defined by [MS-MQQP].
The application is finished utilizing the local queue handle and closes it with a call to the rpc_ACCloseHandle method.
The supporting server closes the remote read session handle (via the qm2qm protocol, as specified in [MS-MQQP]) that was associated with the local queue handle passed by the application at step 13. Note that the supporting server invokes the qm2qm protocol in parallel and does not block the rpc_ACCloseHandle method invocation while the session handle is being closed.