使用MQ Extendend Transaction Client写入队列时发生异常
||
我正在尝试使用.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()调用。因此,除非当前发生异常,否则我希望队列中的消息与事务一起回滚。
没有找到相关结果
已邀请:
1 个回复
习让休堂溯