异常使用MQ Extended Transactional Client写入队列

时间:2011-06-24 22:45:41

标签: .net transactions ibm-mq

我正在尝试使用.NET MQ扩展事务客户端与我们企业中的现有队列管理器进行通信。我正在使用MQ 7.0.1试用版的扩展客户端运行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 个答案:

答案 0 :(得分:2)

原来这是v7客户端中的一个开放问题。我的v7 XA客户端正在与v6队列管理器交谈:

IC74808: MQ V7 XA CLIENT APPLICATION FAILS WHILE CONNECTING TO MQ V6 QUEUE MANAGER.

  

WebSphere MQ v7 XA客户端   应用程序向a发出MQCONN   WebSphere MQ v6队列管理器。该   在xa_open期间,MQCONN失败   原因码2046,MQRC_OPTIONS_ERROR。   这在MSDTC进程中失败了   导致UOW_ENLISTMENT_ERROR,其中   是MQRC = 2354.这也导致了   xa_open调用失败,为-3   (XAER_RMERR)。