我正在尝试对WebSphere Queue原子进行更新并遇到以下问题:一旦调用了_outPutQueue.Put()方法,就会抛出MQ Exception,只是说“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
答案 0 :(得分:0)
试试这个,有一些调整可以加快速度,不是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();
}