0

我目前正在获取所有这样的队列名称:

PCFAgent agent = new PCFAgent(this.HostName, this.Port, this.CHANNEL_NAME);
PCFParameter[] parameters = { new MQCFST(CMQC.MQCA_Q_NAME, "*"), new MQCFIN (CMQC.MQIA_Q_TYPE, CMQC.MQQT_ALL) };
MQMessage[] responses = agent.send(CMQCFC.MQCMD_INQUIRE_Q_NAMES, parameters);
MQCFH cfh = new MQCFH(responses[0]);

但我也得到了远程队列,有没有办法只检索本地和别名队列名称?

4

2 回答 2

4

另一种方法是获取所有队列并简单地选择您想要的类型,而不是执行 2 个 PCF 请求。

PCFAgent agent = new PCFAgent(this.HostName, this.Port, this.CHANNEL_NAME);
PCFParameter[] parameters = { new MQCFST(CMQC.MQCA_Q_NAME, "*"), new MQCFIN (CMQC.MQIA_Q_TYPE, CMQC.MQQT_ALL) };
MQMessage[] responses = agent.send(CMQCFC.MQCMD_INQUIRE_Q_NAMES, parameters);

for (int i = 0; i < responses.length; i++)
{
   // Make sure that each response is ok
   if ((responses[i]).getCompCode() == MQException.MQCC_OK)
   {
      type = responses[i].getIntParameterValue(CMQC.MQIA_Q_TYPE);

      switch (type)
      {
         case CMQC.MQQT_LOCAL:
            // do something with local queue
            break;
         case CMQC.MQQT_MODEL:
            // skip model queue
            break;
         case CMQC.MQQT_ALIAS:
            // do something with alias queue
            break;
         case CMQC.MQQT_REMOTE:
            // skip remote queue
            break;
         case CMQC.MQQT_CLUSTER:
            // skip cluster queue
            break;
         default :
            // something unexpected
            break;
      }
   }
}
于 2013-06-20T16:12:13.833 回答
2

由于您可以指定队列类型,您应该能够通过使用指定的队列类型发出两个调用来获取所需的队列。

PCFParameter[] parameters = { new MQCFST(CMQC.MQCA_Q_NAME, "*"), new MQCFIN (CMQC.MQIA_Q_TYPE, CMQC.MQQT_LOCAL) };
 agent.send(..);
 // etc.. Get local queues
parameters = { new MQCFST(CMQC.MQCA_Q_NAME, "*"), new MQCFIN (CMQC.MQIA_Q_TYPE, CMQC.MQQT_ALIAS) };
 agent.send(..);

 // etc.. get alias queues

 // TODO: now build a list of all queues, local and alias. 
于 2013-06-20T07:15:09.330 回答