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.  Reconnect questions regarding MQ .NET fully managed client (MQNM type)

    Posted Fri January 28, 2022 12:11 PM
    One of our MQ client applications uses the .NET XMS package to connect to a queue as a consumer (9.2.2 version of IBMMQDotnetClient).  We're investigating an issue where it appears the message handler is not responding even though there are messages waiting on the queue.  We are early in the debugging process, though.  The issue is intermittent, which makes it more challenging.  I don't have any experience with this client so I'm reaching out to the larger audience to make sure we're using it correctly. 

    The goal is for the client to detect network issues and automatically attempt to reconnect -- either by allowing XMS to monitor and drive this, or with monitoring code we write in the client.   This is how the connection code is written:
    XMSFactoryFactory factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
    
    // Create WMQ Connection Factory.
    IConnectionFactory connectionFactory = factoryFactory.CreateConnectionFactory();
    
    //Set the properties
    connectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, servicesInfo.HostName); 
    connectionFactory.SetStringProperty(XMSC.WMQ_PORT, servicesInfo.Port);
    connectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, servicesInfo.QueueManagerName);
    connectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, servicesInfo.ChannelName); 
    connectionFactory.SetStringProperty(XMSC.USERID, Globals.mqUserId);
    connectionFactory.SetStringProperty(XMSC.PASSWORD, Globals.mqPwd);
    connectionFactory.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, XMSC.WMQ_CLIENT_RECONNECT);
    connectionFactory.SetStringProperty(XMSC.WMQ_APPLICATIONNAME, ServiceName + "-" + domainName);
    connectionFactory.SetStringProperty(XMSC.WMQ_CONNECTION_NAME_LIST, servicesInfo.HostName + "(" + servicesInfo.Port + ")");
    
    // Create the connection and register an exception listener
    connection = connectionFactory.CreateConnection();
    connection.ExceptionListener = new ExceptionListener(OnException);
    
    session = connection.CreateSession(true, AcknowledgeMode.SessionTransacted);
    
    if (session == null)
    {
    LogFile.WriteToLog("Error in creating connection to WMQ_PROVIDER");
    }
    
    //Create Destination
    destination = session.CreateQueue(servicesInfo.QueueName);
    
    //Create Consumer
    consumer = session.CreateConsumer(destination);
    
    // Setup a message listener and assign it to consumer
    messageListener = new MessageListener(OnMessageReceive);
    consumer.MessageListener = messageListener;
    
    // Start the connection to receive messages.
    connection.Start();​

    and this is the receive handler

    protected void OnMessageReceive(IMessage message)
    {
      ITextMessage Msg = (ITextMessage)message;
      // Log message handler invoked.
      try
      {
        // Process the message
      }
      catch (Exception ex)
      {
        // Log an exception
      }
      finally
      {
        // Handle finally block
      }
    }


    What is the best solution to monitor MQ connectivity with this client and make sure it remains active (or that we report an error in the event we are unable to restore a connection)?

    Thanks



    ------------------------------
    Jim Creasman
    ------------------------------


  • 2.  RE: Reconnect questions regarding MQ .NET fully managed client (MQNM type)

    Posted Mon January 31, 2022 02:46 AM
    Hi 
    Take a look at this apar I guess that's your problem https://www.ibm.com/support/pages/apar/IT34722
    Regards
    Daniel

    ------------------------------
    Daniel Nordkvist
    ------------------------------



  • 3.  RE: Reconnect questions regarding MQ .NET fully managed client (MQNM type)

    Posted Tue February 01, 2022 07:10 PM
    Thanks for the pointers to APAR IT34722.  We were able to recreate this locally and are in the process of upgrading our server with the recommended fix pack.  Hoping that solves the problem.


    ------------------------------
    Jim Creasman
    ------------------------------