使用 MQ Extendend 事务客户端写入队列时发生异常

发布于 2024-11-17 05:51:50 字数 1817 浏览 2 评论 0原文

我正在尝试使用 .NET MQ 扩展事务客户端与我们企业中现有的队列管理器进行通信。我正在全新安装的 Windows 2008 R2 上运行,并带有来自 MQ 7.0.1 试用版的扩展客户端。

当我注释掉 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() 调用。因此,除非出现当前异常,否则我希望队列上的消息会随事务一起回滚。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陈年往事 2024-11-24 05:51:50

事实证明,这是 v7 客户端中的一个未解决问题。我的 v7 XA 客户端正在与 v6 队列管理器通信:

IC74808: MQ V7 XA连接到 MQ V6 队列管理器时客户端应用程序失败。

WebSphere MQ v7 XA 客户端
应用程序向
WebSphere MQ v6 队列管理器。这
MQCONN 在 xa_open 期间失败
原因代码 2046,MQRC_OPTIONS_ERROR。
MSDTC 过程中出现此故障
导致 UOW_ENLISTMENT_ERROR,这
MQRC = 2354。这也导致
xa_open 调用失败并返回 -3
(XAER_RMERR)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文