我有一個Windows服務,它監聽MQ隊列管理器並獲取消息。有一個網絡中斷,並且MQ .Net客戶端停止監聽MQ隊列。他們不是應用程序拋出的例外。所以當我看到事件日誌中出現了一個錯誤WMQ客戶端停止mq得到沒有拋出任何異常
過程(1612.3),用戶(系統)項目(MMQ.Receiver.exe)主機(*****)安裝(Installation1)VRMF(7.5.0.4 )
從主機接收時出錯。
從TCP/IP接收數據時發生錯誤。這可能是由於通訊失敗。
來自TCP/IP(socket.Receive)調用的返回碼是10054(X'2746')。記錄這些值並告訴系統管理員。
而MQ客戶端文件與下面的行具有相同的上述錯誤。
IBM.WMQ.MQTCPConnection.Receive
我應該如何處理這些類型的錯誤。正如我所說的沒有在code.Below拋出的錯誤是我的代碼
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隊列
在我的代碼,它拋出的異常,並嘗試重新連接,直到成功爲止,我有記錄過我剛剛在這段代碼中被刪除。但在這種情況下,沒有從服務中拋出異常,我發現事件中的錯誤記錄應該是什麼情況? – user3067170
有沒有辦法在MQ客戶端上增加默認重新連接超時(即30分鐘)? – user3067170
你是什麼意思30分鐘重新連接超時。一旦連接斷開,您應該能夠重新嘗試連接。如果問題是原來的連接仍然出現在服務器資源鎖定新的連接需求上,考慮你是否正在sharecnv> 0,並使用HBINT(MQv7客戶+),或者需要使用保活(雖然默認爲2小時)。 – JasonE