![](/img/trans.png)
[英]IBM MQ Server Setup to Create CCDT file used by .NET Client
[英]Handling connections in IBM MQ client/server
我是IBM MQ的新手,我的隊列管理器使用tcp通道連接,並且tcp連接大量增加,這是正在使用的代碼段。 如何以可重用的方式處理通道內的連接?
我正在使用7.5 MQ客戶端,正在與6.0.5.2 MQ遠程服務器通信。 我正確關閉了連接,但是當我運行netstat時,它說tcp連接處於time_wait狀態。 這些是連接/插座泄漏嗎?
MQQueue mqQueue = null;
MQQueueManager mqQMgr=null;
try
{
//Create connection to queue manager
mqQMgr = new MQQueueManager("Queue Manager name", properties);
//Access the queue
mqQueue = mqQMgr.AccessQueue(QueueName, MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_INPUT_SHARED | MQC.MQOO_BROWSE);
for(int i=1;i<2000;i++)
{
//read the messages
mqMsg=new MQMessage();
mqQueue.Get(mqMsg);
}
}
catch(MQException mqe)
{
//If no messages in the queue , break. (if not, catch any error)
}
finally
{
mqQueue.Close(); //Close the MQ Queue
mqQMgr.Disconnect(); //Disconnect the MQ Manager
}
當我運行netstat時,它顯示
TCP x.x.x.x:59092 x.x.x.x:1400 TIME_WAIT
TCP x.x.x.x:59093 x.x.x.x:1400 TIME_WAIT
TCP x.x.x.x:59094 x.x.x.x:1400 TIME_WAIT
TCP x.x.x.x:59095 x.x.x.x:1400 TIME_WAIT
TCP x.x.x.x:59096 x.x.x.x:1400 TIME_WAIT
TCP x.x.x.x:59097 x.x.x.x:1400 TIME_WAIT
TCP x.x.x.x:59098 x.x.x.x:1400 TIME_WAIT
TCP x.x.x.x:59099 x.x.x.x:1400 TIME_WAIT
這不是泄漏。 套接字在關閉后進入TIME_WAIT狀態。 套接字在TIME_WAIT中放置更長的時間(例如大約4分鍾)是正常的,具體取決於操作系統。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.