Reply-to queue alias definitions

A reply-to queue alias definition specifies alternative names for the reply information in the message descriptor. The advantage of this is that you can alter the name of a queue or queue manager without having to alter your applications.

Queue name resolution

When an application replies to a message, it uses the data in the message descriptor of the message it received to find out the name of the queue to reply to. The sending application indicates where replies are sent to and attaches this information to its messages. This concept must be coordinated as part of your application design.

Queue name resolution takes place at the sending end of your application, before the message is put to a queue. Queue name resolution therefore occurs before interaction with the remote application that the message is being sent to. This is the only situation in which name resolution takes place at a time when a queue is not being opened.

Queue name resolution using a queue manager alias

Normally an application specifies a reply-to queue and leaves the reply-to queue manager name blank. The queue manager completes its own name at put time. This method works well except when you want an alternative channel to be used for replies, for example, a channel that uses transmission queue QM1_relief instead of the default return channel which uses transmission queue QM1. In this situation, the queue manager names specified in transmission-queue headers do not match "real" queue manager names, but are respecified using queue manager alias definitions. In order to return replies along alternative routes, it is necessary to map reply-to queue data as well, using reply-to queue alias definitions.
Figure 1. Reply-to queue alias used for changing reply location
In the example shown, the message descriptor for messages sent from QM1 specify a reply-to queue alias definition. Replies to these messages are sent to the queue specified. See the text following the example for a more detailed explanation.
In the example in Figure 1:
  1. The application puts a message using the MQPUT call and specifying the following information in the message descriptor:
    
    ReplyToQ='Reply_to'
    ReplyToQMgr=' '
    

    ReplyToQMgr must be blank in order for the reply-to queue alias to be used.

  2. You create a reply-to queue alias definition called Reply_to, which contains the name Answer, and the queue manager name QM1_relief.
    
    DEFINE QREMOTE ('Reply_to') RNAME ('Answer')
    RQMNAME ('QM1_relief')
    
  3. The messages are sent with a message descriptor showing ReplyToQ='Answer' and ReplyToQMgr='QM1_relief'.
  4. The application specification must include the information that replies are to be found in queue Answer rather than Reply_to.
To prepare for the replies you have to create the parallel return channel, defining:
  • At QM2, the transmission queue named QM1_relief
    
    DEFINE QLOCAL ('QM1_relief') USAGE(XMITQ)
    
  • At QM1, the queue manager alias QM1_relief
    
    DEFINE QREMOTE ('QM1_relief') RNAME() RQMNAME(QM1)
    

    This queue manager alias terminates the chain of parallel return channels and captures the messages for QM1.

If you think you might want to do this at sometime in the future, ensure applications use the alias name from the start. For now this is a normal queue alias to the reply-to queue, but later it can be changed to a queue manager alias.

Reply-to queue name

Care is needed with naming reply-to queues. The reason that an application puts a reply-to queue name in the message is that it can specify the queue to which its replies are sent. When you create a reply-to queue alias definition with this name, you cannot have the actual reply-to queue (that is, a local queue definition) with the same name. Therefore, the reply-to queue alias definition must contain a new queue name as well as the queue manager name, and the application specification must include the information that its replies are found in this other queue.

The applications now have to retrieve the messages from a different queue from the one they named as the reply-to queue when they put the original message.