I am trying to use the .NET MQ Extended Transaction Client to talk to an existing Queue Manager in our enterprise. I am running on a clean install of Windows 2008 R2 with the Extended Client from the MQ 7.0.1 trial.
My program writes to the queue when I comment out the TransactionScope and the MQC.MQPMO_SYNCPOINT options. With the transaction code I get the following exception on the q.Put() call:
MQRC_UOW_ENLISTMENT_ERROR ReasonCode 2354
Here is my complete program:
开发者_开发知识库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();
}
}
}
Note that this program does not have a trans.Complete() call. So, barring the current exception, I would expect the message on the queue to be rolled back with the transaction.
It turned out to be an open issue in the v7 client. My v7 XA client was talking to a v6 Queue Manager:
IC74808: MQ V7 XA CLIENT APPLICATION FAILS WHILE CONNECTING TO MQ V6 QUEUE MANAGER.
A WebSphere MQ v7 XA client application issues an MQCONN to a WebSphere MQ v6 queue manager. The MQCONN fails during a xa_open with reason code 2046, MQRC_OPTIONS_ERROR. This failure in the MSDTC process causes a UOW_ENLISTMENT_ERROR, which is MQRC = 2354. This also results in the xa_open call failing with a -3 (XAER_RMERR).
精彩评论