Source Viewer: Mq.InquireQueueNames.cs
Font Size:
1
2
3
4
5
6
7
Mq.InquireQueueNames.cs
Mq.Load.cs
..
// Mq.InquireQueueNames.cs // // This MQ app uses the undocumented PCF support within IBM's MQ // Classes for .NET, to list the queue names on a queue manager. // // // Tested with MQv6.0. with the MQ Server installed locally, all // on a Windows XP SP2 machine. This should also work with MQ Client // and a remote MQ server on Windows or non-Windows, but I // didn't test it that way. // // Note, in the current release of MQ, the MQ Classes for .NET // do not officially support PCF. It just happens to work. // // // compile with: // csc /target:exe /out:Mq.InquireQueueNames.exe /R:amqmdnet.dll Mq.InquireQueueNames.cs // // Mon, 13 Feb 2006 21:21 // using System; using IBM.WMQ; using IBM.WMQ.PCF; namespace Dinoch.Example.Mq { public class InquireQueueNames { public static void Main() { InquireQueueNames me = new InquireQueueNames(); me.Go(); } private void Go() { FindQueueNames(); } private bool useDefaultQm { get { return true; } } private MQQueueManager _mqm = null; private MQQueueManager Mqm { get { if (_mqm==null) _mqm= new MQQueueManager(); return _mqm; } } private string QmName { get { if (!Mqm.IsConnected) Mqm.Connect(); return Mqm.Name; // QueueManagerIdentifier; } } private void FindQueueNames() { try { Console.WriteLine("Using QM:\n '{0}'", QmName.Trim()); // Name has trailing spaces //PCFMessageAgent agent = (useDefaultQm) ? new PCFMessageAgent(): new PCFMessageAgent(tb_QueueMgr.Text); PCFMessageAgent agent = new PCFMessageAgent(QmName); PCFMessage request= new PCFMessage(CMQCFC.MQCMD_INQUIRE_Q_NAMES); request.AddParameter (MQC.MQCA_Q_NAME, "*"); request.AddParameter (MQC.MQIA_Q_TYPE, MQC.MQQT_LOCAL); PCFMessage[] responses = agent.Send(request); if (responses==null) throw new Exception("bogus response from MQ PCF."); else { //Console.WriteLine("Found {0} responses.", responses.Length); if (responses[0].GetCompCode() == MQC.MQCC_OK) { PCFParameter[] p= responses[0].GetParameters(); if ((p!=null) && (p.Length>0)) { string[] names= (string[]) p[0].GetValue(); Array.Sort(names, System.StringComparer.Ordinal); Console.WriteLine("\nQueue Names:"); for (int i = 0; i < names.Length; i++) { Console.WriteLine (" {0}", names[i].Trim()); // name has trailing spaces } Console.WriteLine(); } } } } catch (IBM.WMQ.MQException mqex) { MqExUtil mqexutil= new MqExUtil(); Console.WriteLine("While inquiring queue names, MQ Exception: {0}", mqexutil.ExcFormat(mqex)); } catch (Exception ex1) { Console.WriteLine("While inquiring queue names, Exception:" + ex1); } } } }
The srcview page has been enjoyed 291584 times since 18 September 2003