简体   繁体   中英

Trying to make update to WebSphere MQ Queue atomic

I am trying to make an update to a WebSphere Queue atomic and running into the following problem: Once the _outPutQueue.Put() method is called an MQ Exception is thrown that simply says "MQRC_FUNCTION_NOT_SUPPORTED." This happens because I've wrapped the method call inside a using (CommittableTransaction) block. If I take the method call outside of the block, it works fine. Is this a simply a limitation of writing to a Queue inside 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();                        
       }
 }

As requested here is the full exception information:

MQRC_FUNCTION_NOT_SUPPORTED
Exception | System.Exception
     base {object} | object 
Non-Public members | 
     _COMPlusExceptionCode = -532459699

Try this, there are a few tweaks which will speed things up in general, not 100% sure this will fix your issue, but it may help me diagnose it...

// 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();                       
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM