C# 尝试对WebSphere MQ队列进行原子更新
我试图对WebSphere队列原子进行更新,但遇到了以下问题:一旦调用了_outPutQueue.Put()方法,就会引发一个MQ异常,该异常简单地表示“MQRC_FUNCTION_NOT_SUPPORTED”。发生这种情况是因为我将方法调用包装在using(CommitteableTransaction)块中。如果我将方法调用带到块之外,它就可以正常工作。这仅仅是写入C#内部队列的限制吗 根据要求,以下是完整的例外信息:C# 尝试对WebSphere MQ队列进行原子更新,c#,queue,websphere,atomic,C#,Queue,Websphere,Atomic,我试图对WebSphere队列原子进行更新,但遇到了以下问题:一旦调用了_outPutQueue.Put()方法,就会引发一个MQ异常,该异常简单地表示“MQRC_FUNCTION_NOT_SUPPORTED”。发生这种情况是因为我将方法调用包装在using(CommitteableTransaction)块中。如果我将方法调用带到块之外,它就可以正常工作。这仅仅是写入C#内部队列的限制吗 根据要求,以下是完整的例外信息: MQRC_FUNCTION_NOT_SUPPORTED Exceptio
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();
}
我没有我的开发机器来测试为什么会出现这个问题,你能试试我上面更新的代码吗?检查是否是outputQueue的第一次运行。将导致错误的原因放入第二次、第三次等,然后通知我。希望这能解决你的问题。使用语句基本上只需调用对象上的dispose…只要运行这个(复制并粘贴),它就会在第一次调用_outputQueue.Put()时抛出一个异常。循环无法进入第二次迭代。能否更新帖子以包含完整的异常信息?完成。所有caps中的异常都是MQException VS catch。其余的在“catch(Exception)”行旁边的白色对话框中。
// 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();
}