简体   繁体   English

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

[英]Is it possible to get only the queue names of local and alias queues?

I'm currently getting all of the queue names like this: 我目前正在获得所有这样的队列名称:

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

But I'm also getting remote queues, is there a way to retrive only local and alias queue names? 但是我也有远程队列,有没有办法只检索本地和别名队列名称?

Instead of doing 2 PCF requests, the other approach is to get all of the queues and simply select the type you want. 代替执行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;
      }
   }
}

As you can specify the queue type, you should be able to grab the desired queues by issuing two calls with your specified queue type. 当您可以指定队列类型时,您应该能够通过发出两个具有指定队列类型的呼叫来捕获所需的队列。

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. 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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