简体   繁体   中英

How To Set WebSphereMQ Message Transmission Header for Queue Manager Alias

I'm trying to put a message on a remote queue which is not defined locally on the queue manager (queue manager alias). I'm being told to put the remote queue manager name in the message transmission header so it will be routed to the appropriate transmission queue.

I'm able to connect to the internal queue manager with the following:

Hashtable properties = new Hashtable();
properties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_MANAGED);
properties.Add(MQC.HOST_NAME_PROPERTY, hostName);
properties.Add(MQC.PORT_PROPERTY, port);
properties.Add(MQC.CHANNEL_PROPERTY, channelName);    

MQQueueManager queueManager = new MQQueueManager(queueManagerName, properties);

I create the message and attempt to do the Put but I'm not sure where/how to set the transmission header to the destination queue manager name.

message = new MQMessage();
message.Format = MQC.MQFMT_STRING;
message.WriteString(messageString);

queueManager.Put( ???qName???, ???qmName???, message);

I've tried using a blank qName and get an [MQRC_REMOTE_Q_NAME_ERROR]

UPDATE : Turned out that they configured the queue manager alias incorrectly. The answer below helped me point it out to them. As the accepted answer states, MQ handles the message transmit header for you. Once it was configured correctly it was the same as putting a message on a locally defined remote queue.

To answer the question in your headline, you don't need to set the XMit header as MQ will do this for you.

Responding to the body of the question, it's all in how MQ resolves queue names. In the case you present, you tell MQ where to send the message when you open the destination queue. MQ then follows a resolution process to determine where to put the message.

When you specify QNAME but no RQMNAME or when RQMNAME is the local queue manager, then MQ looks for a local queue. When you specify QNAME and where RQMNAME is not the local queue manager, MQ looks for an XMitQ that leads to the named QMgr. If it finds one it puts your message there and includes the required XMitQ header.

MQ finds the right XMitQ by looking to see if one has the same name as the destination QMgr. If not them it looks for QREMOTE definitions with that name and a blank RNAME , and uses the XMITQNAME value. (Because that kind of QREMOTE points to the entire QMgr, it can't specify an RNAME . That is called a QMgr Alias since it defines the relationship between a QMgr and the XMitQ that points to it.)

For a detailed explanation, please see Queue name resolution in the Infocenter.

Note that the ID putting the message will require access to the transmission queue. Granting access allows the app to address messages to any queue on the remote node, including SYSTEM.* queues. It is the responsibility of the receiving QMgr to set the channel's MCAUSER to an account ID that does not have access to administrative queues if this is an issue. On the local queue manager a QREMOTE definition that points to the remote queue can be authorized instead of the XMit queue to prevent such broad access.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM