[英]Trying to make update to WebSphere MQ Queue atomic
我正在尝试对WebSphere Queue原子进行更新,并遇到以下问题:调用_outPutQueue.Put()方法后,将引发MQ异常,该异常仅显示“ MQRC_FUNCTION_NOT_SUPPORTED”。 发生这种情况是因为我已将方法调用包装在using(CommittableTransaction)块内。 如果我将方法调用放在块之外,则可以正常工作。 这仅仅是在C#中写入队列的限制吗?
using (CommittableTransaction transScope = new CommittableTransaction())
{
CommittableTransaction.Current = transScope;
try
{
foreach (string agentItem in qSqlContents.Values)
{
// Define a WebSphere MQ message, writing some text in UTF format
MQMessage mqMessage = new MQMessage();
mqMessage.Write(StrToByteArray(agentItem));
// Specify the message options
MQPutMessageOptions pmo = new MQPutMessageOptions();
// MQC.MQPMO_SYNCPOINT = provide transaction support for the Put.
pmo.Options = MQC.MQPMO_SYNCPOINT;
// Put the message on the queue
_outputQueue.Put(mqMessage, pmo);
}
}
catch (Exception)
{
transScope.Rollback();
}
finally
{
transScope.Commit();
}
}
根据要求,这里是完整的异常信息:
MQRC_FUNCTION_NOT_SUPPORTED
Exception | System.Exception
base {object} | object
Non-Public members |
_COMPlusExceptionCode = -532459699
尝试此操作,有一些调整可以总体上加快速度,但不是100%确定这可以解决您的问题,但这可能有助于我进行诊断...
// Specify the message options
MQPutMessageOptions pmo = new MQPutMessageOptions();
// MQC.MQPMO_SYNCPOINT = provide transaction support for the Put.
pmo.Options = MQC.MQPMO_SYNCPOINT;
CommittableTransaction transScope = new CommittableTransaction();
CommittableTransaction.Current = transScope;
try
{
foreach (string agentItem in qSqlContents.Values)
{
// Define a WebSphere MQ message, writing some text in UTF format
MQMessage mqMessage = new MQMessage();
mqMessage.Write(StrToByteArray(agentItem));
// Put the message on the queue
_outputQueue.Put(mqMessage, pmo);
}
}
catch (Exception)
{
transScope.Rollback();
}
finally
{
_outputQueue.close();
transScope.Commit();
transScope.Dispose();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.