MQ is a product designed to send data (messages) from one destination to another. Despite this most installations use MQ for remote procedure calls (RPC). To support this functionality MQ is provided with some facilities that I will briefly introduce to you in this tip.
Along with every MQ message there is a message descriptor (MD) and this message descriptor contains two interesting fields. These two fields are called ReplyToQ and ReplyToQMgr. Before a message is sent you may assign the name of the local queue to receive the answer to the field ReplyToQ. Make sure that the field ReplyToQMgr is filled with spaces.
When the message is received, the receiver is able to send the reply to the queue manager in field ReplyToQMgr and the queue name in field ReplyToQ. The sending queue manager will fill in its name in ReplyToQMgr if the field is filled with spaces. The name in ReplyToQ must be an existing local queue defined on the sending queue manager.
All this can be hard to understand, so let us look at an example. Here is what the sender must do:
OD is the object descriptor and ObjectName is the name of the queue that sends the message. At the receiver the message is processed and the reply is sent is the following way:
To make all this simple stuff work at the receiver, you must ensure that the XMIT queue at the receiver has the same name as the name of the sending queue manager. In other words there has to exist a XMIT queue at the receiver that correspond to the name assigned to field ReplyToQMgr and this XMIT queue must refer to the sending queue manager. It might work even though these rules aren't followed. I will return to this subject in another tip.
The whole idea of all this is that you don't have to define a remote queue at the receiver. The use of a reply remote queue at the receiver will ensure that the receiver can only reply to one queue manager. In this situation other queue managers will never receive a reply because the reply always will be sent to the queue manager that the remote queue refers to. This is not the idea of RPC.
At last but not least I must warn you that using the technique decribed here will require additional RACF authorization. If RACF authorizations are missing, you must look in the MSTR task of the involved queue managers to identify what authorizations are missing. Both the sending queue manager and the receiving queue manager may cause authorization problems.