我们需要从 MB 流发出一些 MQ 命令。
解决方法是发送 PCF 命令,但我不知道如何创建它。
有什么指点吗?
塞巴斯蒂安.
要通过 PCF 消息向 MQ 队列管理器发出命令,您可以查看 *nix 上或安装 MQ 的位置的 /opt/mqm/samp/pcf/samples 中的示例。 (在 Windows 上尝试“C:\Program Files (x86)\IBM\WebSphere MQ\tools\pcf\samples”)。
要从代理发出命令,您可以使用 Java 计算节点并使用提供的 Java 包 com.ibm.mq 中的方法,例如发送查询以找出队列管理器上定义了哪些队列:
import com.ibm.mq.headers.pcf.PCFMessageAgent;
import com.ibm.mq.headers.pcf.PCFMessage;
import com.ibm.mq.constants.MQConstants;
try
{
// local queue manager
String queueManager = "QMGR_broker"; // local queue manager name
PCFMessageAgent agent = new PCFMessageAgent(queueManager);
// remote queue manager
String host = "localhost"; // host name of the queue manager machine
int port = 1414; // default queue manager tcp listener port
String channel = "SYSTEM.DEF.SVRCONN";//Default channel
PCFMessageAgent agent = new PCFMessageAgent(host, port, channel);
// Create the PCF message type for the inquire.
PCFMessage pcfCmd = new PCFMessage(MQConstants.MQCMD_INQUIRE_Q_NAMES);
// Queue name = wildcard.
pcfCmd.addParameter(MQConstants.MQCA_Q_NAME, "*");
// Queue type = ALL.
pcfCmd.addParameter(MQConstants.MQIA_Q_TYPE, MQConstants.MQQT_ALL);
// Execute the command. The returned object is an array of PCF messages.
PCFMessage[] pcfResponse = pcfCM.agent.send(pcfCmd);
// e.g. extract the queue names from the response object
String[] names = (String[])pcfResponse[0].getParameterValue(MQConstants.MQCACF_Q_NAMES);
}
或者,您可以将 PCF 消息放在队列管理器正在侦听事件的 MQ 队列(SYSTEM.ADMIN.COMMAND.QUEUE,如果您使用的是 z/OS 以外的其他系统)。然后,您还需要在消息中定义“回复”队列。您可以通过具有 MQOutput 节点的代理来执行此操作。
然而,这意味着您需要了解PCF消息的确切格式我认为使用提供的 Java 示例来为您进行消息处理和格式化要容易得多。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)