【发布时间】:2015-11-12 17:32:45
【问题描述】:
我有一个侦听 MQ 队列管理器并获取消息的 Windows 服务。发生网络中断,MQ .Net 客户端停止侦听 MQ 队列。应用程序也不例外。所以当我看到事件日志时出现了错误
进程(1612.3) 用户(SYSTEM) 程序(MMQ.Receiver.exe) 主机(*****) 安装(Installation1) VRMF(7.5.0.4)
从主机接收错误。
从 TCP/IP 接收数据时出错。这可能是由于通信故障。
TCP/IP (socket.Receive) 调用的返回码是 10054 (X'2746')。记录这些值并告诉系统管理员。
MQ 客户端文件与下面一行有同样的错误。
IBM.WMQ.MQTCPConnection.Receive
我应该如何处理这些类型的错误。正如我所说,代码中没有抛出错误。下面是我的代码
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
}
}
注意:RetryConnection 重新连接到 MQ 队列
【问题讨论】: