簡體   English   中英

嘗試對WebSphere MQ Queue原子進行更新

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM