使用c#操作IBM WebSphere MQ

CloudSpace發表於2008-07-24
  IBM WebSphere MQ 5.3升級到CSD05之後,提供了使用.net操作MQ的類庫,安裝完成之後,會在MQ的安裝目錄的bin資料夾下面多出一個amqmdnet.dll檔案,把這個DLL作為引用新增到你的.net工程中,你的.net程式中就可以操作IBM WebSphere MQ。
    我的MQ是中文版的,作業系統是win2k003 sp1,無論是在佇列管理器,還是用程式碼新建的佇列,都與我本機時間相差8小時,不曉得何解,哪位高人可以釋疑?

//新建本地佇列           
PCFMessageAgent agent = new PCFMessageAgent("QM_janus");
            PCFMessage request = new PCFMessage(CMQCFC.MQCMD_CREATE_Q);
            request.AddParameter(MQC.MQCA_Q_NAME, "test_queue");
            request.AddParameter(MQC.MQIA_Q_TYPE, MQC.MQQT_LOCAL);
            //request.AddParameter(MQC.MQIA_USAGE, MQC.MQUS_TRANSMISSION);
            PCFMessage[] response = agent.Send(request);

//刪除佇列
            PCFMessageAgent agent = new PCFMessageAgent("QM_janus");
            PCFMessage request = new PCFMessage(CMQCFC.MQCMD_DELETE_Q);
            request.AddParameter(MQC.MQCA_Q_NAME, "test_queue");
            PCFMessage[] response = agent.Send(request);

//從佇列中讀取訊息
            MQQueueManager qMgr = new MQQueueManager("QM_janus");
            MQQueue queue = qMgr.AccessQueue("postcard", MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING);
            MQGetMessageOptions gmo = new MQGetMessageOptions();
            gmo.Options = MQC.MQGMO_WAIT;
            gmo.WaitInterval = 1000;
            gmo.MatchOptions = MQC.MQMO_NONE;
            MQMessage message = new MQMessage();
            queue.Get(message);
 
 //向佇列寫訊息
            MQQueueManager qMgr = new MQQueueManager("QM_janus");
            MQQueue queue = qMgr.AccessQueue("postcard", MQC.MQOO_OUTPUT);
            MQMessage message = new MQMessage();
            message.WriteString("message body");
            queue.Put(message);

//列舉所有佇列
            PCFMessageAgent agent = new PCFMessageAgent("QM_janus");
            PCFMessage request = new PCFMessage(CMQCFC.MQCMD_INQUIRE_Q_NAMES);
            request.AddParameter(MQC.MQCA_Q_NAME, "*");
            PCFMessage[] response = agent.Send(request);
            string[] names = response[0].GetStringListParameterValue(CMQCFC.MQCACF_Q_NAMES);

 http://www.cnblogs.com/janus1999/archive/2006/09/11/501133.html

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14789789/viewspace-409928/,如需轉載,請註明出處,否則將追究法律責任。

相關文章