samwell
samwell

Reputation: 2797

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?

Upvotes: 0

Views: 1776

Answers (2)

Roger
Roger

Reputation: 7456

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

Upvotes: 4

Petter Nordlander
Petter Nordlander

Reputation: 22279

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. 

Upvotes: 2

Related Questions