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