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

旧时模样 提交于 2019-12-23 04:33:06

问题


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?


回答1:


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. 



回答2:


Instead of doing 2 PCF requests, the other approach is to get all of the queues and simply select the type you want.

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;
      }
   }
}


来源:https://stackoverflow.com/questions/17200789/is-it-possible-to-get-only-the-queue-names-of-local-and-alias-queues

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!