是否可以只获取本地和别名队列的队列名称?

时间:2013-06-19 20:34:42

标签: java ibm-mq

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

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]);

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

2 个答案:

答案 0 :(得分: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;
      }
   }
}

答案 1 :(得分: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.