我发现这段代码可以枚举 QueueManager 的队列列表。它有效,但我在它提供的列表中看到了很多系统队列,甚至频道名称。是否有一些属性我可以测试以查看它是否是“正常”用户定义的队列?ObjectType、QueueType、Usage 似乎总是为每个队列名称提供相同的值。
// 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);
}
}
}