I found this code to enumerate a list of queues for a QueueManager.
It works, but I see a lot of System Queues, and even channel names in the list it provides. Is there some property I can test to see if it is a “normal” user-defined queue?
ObjectType, QueueType, Usage seemed to always give same values for every queue-name.
// GET QueueNames - this worked on 07/19/2012 - but returned a lot of system queue, and unclear how to separate user queues from system queues.
PCFMessageAgent agent = new PCFMessageAgent(mqQMgr);
// Build the query request.
PCFMessage requestMessage = new PCFMessage(CMQCFC.MQCMD_INQUIRE_Q_NAMES);
requestMessage.AddParameter(MQC.MQCA_Q_NAME, "*");
// Send the request and retrieve the response.
PCFMessage[] responses = agent.Send(requestMessage);
// Retrieve the values requested from the response.
string[] queueNames = responses[0].GetStringListParameterValue(CMQCFC.MQCACF_Q_NAMES);
//string[] objType = responses[0].GetStringListParameterValue(CMQCFC.MQIACF_OBJECT_TYPE);
int loopCounter = 0;
foreach (string queueName in queueNames)
{
loopCounter++;
Console.WriteLine("QueueName=" + queueName);
try
{
mqQueue = mqQMgr.AccessQueue(
queueName,
MQC.MQOO_OUTPUT // open queue for output
+ MQC.MQOO_INQUIRE // inquire required to get CurrentDepth
+ MQC.MQOO_FAIL_IF_QUIESCING); // but not if MQM stopping
Console.WriteLine("QueueName=" + queueName +
" CurrentDepth=" + mqQueue.CurrentDepth +
" MaxDepth=" + mqQueue.MaximumDepth +
" QueueType=" + mqQueue.QueueType +
" Usage=" + mqQueue.Usage
);
}
catch (MQException mex)
{
Console.WriteLine(mex.Message);
}
}
}
For me your sample code lists only queues, no other objects but yes it lists all queues. You can add another filter
requestMessage.AddParameter(MQC.MQIA_Q_TYPE, MQC.MQQT_MODEL);to list only model queues. Other values available forMQC.MQIA_Q_TYPEareMQC.MQQT_LOCAL,MQQT_ALIAS,MQQT_CLUSTERandMQC.MQQT_REMOTE.All system or predefined queue names begin with
SYSTEM. So you could probably use this string filter out predefined queues after listing. Also if you look at a queue definition, there is DEFTYPE attribute, system defined queues have value ofPREDEFINED. But I could not add a third parameter to filter queue names by DEFTYPE. I got 3014 reason code.HTH