【问题标题】:WebSphere Message Broker - how to send a PCF messageWebSphere Message Broker - 如何发送 PCF 消息
【发布时间】:2014-04-16 06:36:46
【问题描述】:

我们需要从 MB 流中发出一些 MQ 命令。 要走的路是发送一个PCF命令,但我不知道如何创建它。 任何指针? 塞巴斯蒂安。

【问题讨论】:

    标签: ibm-mq broker


    【解决方案1】:

    要通过 PCF 消息向 MQ 队列管理器发出命令,您可以查看 *nix 上 /opt/mqm/samp/pcf/samples 中的示例或您安装 MQ 的位置。 (在 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 节点的代理执行此操作。

    然而,这意味着您需要知道您要发送的exact format of the PCF message 以及它的回复是什么样的,我认为使用提供的 Java 示例为您进行消息处理和格式化要容易得多。

    【讨论】:

      猜你喜欢
      • 2011-01-16
      • 2015-08-27
      • 2012-02-19
      • 2012-11-24
      • 2013-11-04
      • 1970-01-01
      • 2011-12-20
      • 2016-02-18
      • 2015-01-30
      相关资源
      最近更新 更多