MQ

MQ

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  MQ XMS.NET Error while acknowledging a message

    Posted 02/06/25 09:12 AM

    Hello MQ Experts,

    Greetings.

    We're seeing a strange issue (not frequently) since last 2-4 weeks while acknowledging a message using message consumer.

    It's throwing an error while acknowledging the message:

    The method MQCMIT failed.

    A IBM MQ call failed.

    Please see the linked exception for more information. StackTrace =    at IBM.XMS.Client.WMQ.WmqSession.Syncpoint(Boolean commit, Boolean fromOnMessage, String methodName)

       at IBM.XMS.Client.WMQ.WmqSession.Commit(Boolean fromOnMessage)

       at IBM.XMS.Client.Impl.XmsSessionImpl.CommitTransaction()

       at IBM.XMS.Client.Impl.XmsMessageImpl.Acknowledge()

    Code:

     LogMessage($"CreateConsumerIn: Start creating Message Consumer connection ", Tracing.LogCategory.Info, Tracing.LogLevel.NormalLow, null);
    
                    // Get an instance of factory.
                    xmsFactoryIn = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
                    // Create WMQ Connection Factory.
                    connectionFactoryIn = xmsFactoryIn.CreateConnectionFactory();
                    // Set the properties
    
                    if (MQMode == (int)Location.Local)
                    {
                        LogMessage($"CreateConsumerIn: MQ Location=Local ", Tracing.LogCategory.Debug, Tracing.LogLevel.DebugLow, null);
    
                    }
                    else if (MQMode == (int)Location.Remote)
                    {
                        connectionFactoryIn.SetStringProperty(XMSC.WMQ_HOST_NAME, MQHostName);
                        connectionFactoryIn.SetIntProperty(XMSC.WMQ_PORT, MQPort);
                        connectionFactoryIn.SetStringProperty(XMSC.WMQ_CHANNEL, MQChannel);
                        LogMessage($"CreateConsumerIn: MQ Location=Remote. MQHostName = {MQHostName} MQPort = {MQPort} MQChannel = {MQChannel} ", Tracing.LogCategory.Debug, Tracing.LogLevel.DebugLow, null);
                    }
    
                    connectionFactoryIn.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
                    connectionFactoryIn.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, MQManagerName);
                    connectionFactoryIn.SetStringProperty(XMSC.WMQ_QUEUE_NAME, MQQueueNameIn);
    
                    // In case of network issues - reconnect to same queue manager
                    connectionFactoryIn.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, XMSC.WMQ_CLIENT_RECONNECT_Q_MGR);
                    connectionFactoryIn.SetStringProperty(XMSC.WMQ_CONNECTION_NAME_LIST, String.Format("{0}({1})", MQHostName, MQPort));
                    connectionFactoryIn.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT, ReconnectInterval);
                   
                    // Create connection.
                    connectionIn = connectionFactoryIn.CreateConnection();
                    LogMessage($"CreateConsumerIn: MQ Connection created - {this.Name}", Tracing.LogCategory.Debug, Tracing.LogLevel.DebugMedium, null);
                    connectionIn.ExceptionListener = new ExceptionListener(OnExceptionIn);
                    // Create session
                    sessionIn = connectionIn.CreateSession(false, AcknowledgeMode.ClientAcknowledge);
                    LogMessage($"CreateConsumerIn: MQ Session created - {this.Name}", Tracing.LogCategory.Debug, Tracing.LogLevel.DebugMedium, null);
    
                    // Create destination           
                    destinationIn = sessionIn.CreateQueue(MQQueueNameIn);
                    destinationIn.SetIntProperty(XMSC.WMQ_READ_AHEAD_ALLOWED, XMSC.WMQ_READ_AHEAD_ALLOWED_ENABLED);
                    LogMessage($"CreateConsumerIn: MQ Destination created - {this.Name}", Tracing.LogCategory.Debug, Tracing.LogLevel.DebugMedium, null);
    
                    // Create consumer
                    messageConsumerIn = sessionIn.CreateConsumer(destinationIn);
                    LogMessage($"CreateConsumerIn: MQ Consumer created - {this.Name}", Tracing.LogCategory.Debug, Tracing.LogLevel.DebugMedium, null);
    
                    //Create message listener and assign it to the Message consumer
                    messageListenerIn = new MessageListener(OnMessage);
                    messageConsumerIn.MessageListener = messageListenerIn;
                    connectionIn.Start();
    
    
    private void OnMessage(IMessage rawIMessage)
            {
                try
                {
                    if (rawIMessage != null)
                    {
     //do some work
    rawIMessage.Acknowledge();
                       }
                }
                //log mq the error, don't throw the error message.
                catch (XMSException ex)
                {
                    string message = $"OnMessage: MQ Error Caught at CATCH 13";
                    LogException(message, ex, true);
                    throw ex;
                }          
                //log the error, don't throw the error message.
                catch (Exception ex)
                {
                    string message = $"OnMessage: Error Caught at CATCH 13";
                    LogException(message, ex);
                }
    }

     



    ------------------------------
    Balaji Malipatil
    ------------------------------


  • 2.  RE: MQ XMS.NET Error while acknowledging a message

    Posted 02/09/25 12:58 AM

    Hi Balaji,

    > Please see the linked exception for more information.

    Where is the linked exception? We should be able to the MQRC in the linked exception. That's probably what we need here.

    It might be worth checking the queue manager error logs to see if the queue manager has anything to say about this issue there too though.

    Cheers,
    Morag



    ------------------------------
    Morag Hughson
    MQ Technical Education Specialist
    MQGem Software Limited
    Website: https://www.mqgem.com
    ------------------------------



  • 3.  RE: MQ XMS.NET Error while acknowledging a message

    Posted 02/10/25 02:24 AM

    Hi Morag,

    Thank you for your reply.
    I don't see any error in the queue manager logs.
    I was using normal Exception, not the XMSException call, that's why it did capture only this Infromation, not the linked exception. 

    I've modified the code to use XMSException class. I'll share here if we face the problem again.



    ------------------------------
    Balaji Malipatil
    ------------------------------