使用 MQ Extendend 事务客户端写入队列时发生异常
我正在尝试使用 .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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,这是 v7 客户端中的一个未解决问题。我的 v7 XA 客户端正在与 v6 队列管理器通信:
IC74808: MQ V7 XA连接到 MQ V6 队列管理器时客户端应用程序失败。
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.