1

我正在尝试更新 WebSphere Queue atomic 并遇到以下问题:一旦调用 _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
4

1 回答 1

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();                       
}
于 2012-08-14T20:36:37.707 回答