问题描述
||
我正在尝试使用.NET MQ扩展事务客户端与我们企业中的现有队列管理器进行对话。我正在使用MQ 7.0.1试用版的Extended Client在Windows 2008 R2的全新安装上运行。
当我注释掉TransactionScope和MQC.MQPMO_SYNCPOINT选项时,程序将写入队列。使用事务代码,我在q.Put()调用中收到以下异常:
MQRC_UOW_ENLISTMENT_ERROR ReasonCode 2354
这是我完整的程序:
using System;
using System.Collections.Generic;
using System.Text;
using IBM.WMQ;
using System.Transactions;
namespace MQSeries
{
class Program
{
static void Main(string[] args)
{
var transOptions = new Transactionoptions();
transOptions.IsolationLevel = IsolationLevel.Serializable;
string queueManagerName = \"MYQUEUEMANAGER\";
string queueName = \"MYQUEUE\";
string channelName = \"MYCHANNEL\";
string channelInfo = \"myserver.com(1418)\";
MQQueueManager qm;
using (var trans = new TransactionScope(TransactionScopeOption.required,transOptions,EnterpriseServicesInteropOption.Full))
{
qm = new MQQueueManager(queueManagerName,channelName,channelInfo);
// Set up the options on the queue we wish to open
int openoptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
var q = qm.AccessQueue(queueName,openoptions);
// Define a WebSphere MQ message,writing some text in UTF format
MQMessage hello_world = new MQMessage();
hello_world.WriteUTF(\"Hello World!\");
// Specify the message options
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults,pmo.Options = MQC.MQPMO_SYNCPOINT;
// Put the message on the queue
q.Put(hello_world,pmo);
}
qm.disconnect();
}
}
}
请注意,该程序没有trans.Complete()调用。因此,除非当前发生异常,否则我希望队列中的消息与事务一起回滚。
解决方法
事实证明,这是v7客户端中的一个未解决的问题。我的v7 XA客户端正在与v6队列管理器对话:
IC74808:MQ V7 XA客户应用程序在连接到MQ V6队列管理器时失败。
WebSphere MQ v7 XA客户端
应用程序将MQCONN发出给
WebSphere MQ v6队列管理器。的
在执行xa_open期间,MQCONN失败
原因码2046,MQRC_OPTIONS_ERROR。
MSDTC流程中的此失败
导致UOW_ENLISTMENT_ERROR,
是MQRC =2354。这也导致
xa_open调用以-3失败
(XAER_RMERR)。