問題描述
Cách lấy tên hàng đợi MQSeries trong .NET mà không có 2068 (How to get MQSeries queuename in .NET without 2068)
I have a generic 'datapump' that is running is part of a Windows service; an instance of it exists for each queue that I'm monitoring for new incoming messages from an MQSeries queue. If the Get method fails, I want to be able to show the name of the queue, so I'm trying to build a debug variable that can be used in the catch handler. I'm getting a 2068 MQRC_SELECTOR_NOT_FOR_TYPE on the line that sets debugQueueInfo below.
debugLocation = "queueGetName";
debugQueueInfo = "Queue:" + queueIn.RemoteQueueManagerName + ":"
+ queueIn.RemoteQueueName;
debugLocation = "queueGetMessage";
queueIn.Get(mqMessage, mqGetMessageOptions);
How can I get the current queue manager name, and queue name? The variable queueIn is of type IMB.WMQ.MQQueue, and I'm using the .NET API.
When the queue was object was built, I used the following:
queueOptions = MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INQUIRE + MQC.MQOO_BROWSE;
MQQueue mqQueue = qmgr.AccessQueue(mqCloneSpecs.queueName, queueOptions);
Based on the doc of the error code for 2068, I thought maybe adding the MQC.MQOO_BROWSE would fix the issue, but it did not.
參考解法
方法 1:
RemoteQueueManagerName and RemoteQueueName are valid for remote queues only. I think that's the reason why you are getting 2068. MQOO_BROWSE otpion is for getting a message without removing it from the queue.
You can use Name
property to get the queue name, like
debugQueueInfo = "Queue:" + queueIn.Name;
MQQueue
class does not have a property to get the queue manager name. You will have to get it from MQQueueManager instance.
(by NealWalters、Shashi)