我正嘗試使用.NET MQ Extended Transaction Client與我們企業中的現有隊列管理器對話。我正在使用MQ 7.0.1試用版的擴展客戶端在乾淨安裝的Windows 2008 R2上運行。異常使用MQ Extendend Transaction Client寫入隊列
當我註釋掉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( )電話。所以,除了當前的異常,我希望隊列中的消息被事務回滾。