0
我是IBM MQ的新手,我的队列管理器使用tcp通道连接,并且tcp连接广泛存在,这是我正在使用的代码片断。如何以可重用的方式处理频道内的连接?在IBM MQ客户机/服务器中处理连接
我正在使用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
任何输入信息会有帮助吗? – Sharpeye500