還有就是在MQ .NET PCF支持一定的水平,但它是無證。以下是在隊列管理器中顯示隊列名稱的示例代碼。
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IBM.WMQ;
using IBM.WMQ.PCF;
namespace PCFNET
{
class Program
{
static void Main(string[] args)
{
InquireQueue();
}
/// <summary>
/// Display list of queue names and queue depth for each queue
/// </summary>
public static void InquireQueue()
{
PCFMessageAgent messageAgent = null;
try
{
// Create bindings connection to queue manager
messageAgent = new PCFMessageAgent("DEMOQMGR");
// Build Inquire command to query queue name
PCFMessage reqeuestMessage = new PCFMessage(MQC.MQCMD_INQUIRE_Q);
reqeuestMessage.AddParameter(MQC.MQCA_Q_NAME, "*");
// Send request and receive response
PCFMessage[] pcfResponse = messageAgent.Send(reqeuestMessage);
// Process and print response.
int pcfResponseLen = pcfResponse.Length;
for (int pcfResponseIdx = 0; pcfResponseIdx < pcfResponseLen; pcfResponseIdx++)
{
try
{
String qName = pcfResponse[pcfResponseIdx].GetStringParameterValue(MQC.MQCA_Q_NAME);
int qDepth = pcfResponse[pcfResponseIdx].GetIntParameterValue(MQC.MQIA_CURRENT_Q_DEPTH);
Console.WriteLine("QName: " + qName + " Depth: " + qDepth);
}
catch (PCFException pcfex)
{
//Ignore exception and get the next response
}
}
}
catch (PCFException pcfEx)
{
Console.Write(pcfEx);
}
catch (MQException ex)
{
Console.Write(ex);
}
catch (Exception ex)
{
Console.Write(ex);
}
finally
{
if (messageAgent != null)
messageAgent.Disconnect();
}
}
}
}
我得到QueueNameException(2058)錯誤調用InquireQueue()方法時。我試圖在建立活動會話(到其他隊列)時以及在使用有效連接數據創建MqQueueManager對象之後直接執行此操作。我在展位案例中遇到同樣的錯誤。拋出異常: 'IBM.WMQ.MQException' 在amqmdnet.dll,CompCode:2,原因是:2058調用InquireQueue當()梅託德。由於我建立了連接,我知道MQ的權利是正確的。我無法看到QueueManager名稱在InquireQueue()方法中與MQQueueManager中的相關。 –
你在例子中忘了這個嗎? –
該示例連接到本地隊列管理器DEMOQMGR,因爲您可以看到名稱傳遞給PCFMessageAgent類的構造函數。原因碼2058意味着隊列管理器名稱錯誤。您是否連接到本地隊列管理器或遠程隊列管理器。如果是遠程隊列管理器,那麼您需要通過提供通道名稱,主機和詩人編號來創建具有客戶端連接的MQQueueManager類實例。 – Shashi