0
votes

I have a windows service which listens to the MQ queue manager and get messages. There was a network interuption and MQ .Net client stopped listening to MQ Queue. They was no exception thrown by the application. So when i saw the event logs there was a error

Process(1612.3) User(SYSTEM) Program(MMQ.Receiver.exe) Host(*****) Installation(Installation1) VRMF(7.5.0.4)

Error on receive from host .

An error occurred receiving data from over TCP/IP. This may be due to a communications failure.

The return code from the TCP/IP (socket.Receive) call was 10054 (X'2746'). Record these values and tell the systems administrator.

And the MQ client file has the same above error with the below line.

IBM.WMQ.MQTCPConnection.Receive

How should i handle these type of error. As i said there was no error thrown in the code.Below is my code

try
            {
                if (queuereceive == null)
                {                        
                    RetryConnection();
                }
                else
                {
                    inboundmsg = new MQMessage();                        
                    queuereceive.Get(inboundmsg, queueGetMessageOptions);

                    //code where it receives the message and do the process 

                    inboundmsg.ClearMessage();
                }
            }
            catch (MQException mqe)
            {
                inboundmsg = null;
                if (mqe.Reason == MQC.MQRC_NO_MSG_AVAILABLE)
                {

                }
                else if (mqe.Reason == MQC.MQRC_CONNECTION_QUIESCING || mqe.Reason == MQC.MQRC_CONNECTION_BROKEN)
                {
                    if (queueManagerreceive != null)
                    if (queueManagerreceive.IsConnected)
                    {
                        queueManagerreceive.Disconnect();
                    }

                    RetryConnection(); //retire connection if an exception is thrown 
                }
                else
                {
                    Logger.Error(string.Format("MQQueue::Get ended with {0} ", mqe.Message));
                    if (queueManagerreceive != null)
                    if (queueManagerreceive.IsConnected)
                    {
                        queueManagerreceive.Disconnect();
                    }

                    // treat truncated message as a failure 
                    if (mqe.Reason == MQC.MQRC_TRUNCATED_MSG_FAILED)
                    {
                        Logger.Error(string.Format("MQQueue::Get ended with {0}  ", mqe.Message));
                    }

                    RetryConnection(); //retire connection if an exception is thrown 
                }
            }

Note: RetryConnection reconnects to the MQ queue

1

1 Answers

0
votes

Try adding logging into the connection broken exception handling case. I think your client application is just getting thrown an MQException of type MQRC_CONNECTION_BROKEN - in which case your code silently disconnects and reconnects. (Note 10054 usually means the other end has decided to close the connection which would tie up here if there was a network issue)