|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Leaking TCP connections disconnecting from remote QM |
« View previous topic :: View next topic » |
Author |
Message
|
doug |
Posted: Thu Mar 03, 2005 8:26 am Post subject: Leaking TCP connections disconnecting from remote QM |
|
|
Novice
Joined: 27 May 2003 Posts: 11
|
I have a single threaded application using the MQ .NET classes, to receive messages from a number of queues, potentially on different queue managers. Therefore, if I want to switch queue managers, I have to disconnect from the old one and connect to the new one. (I accept that this isn't the most efficient way of doing things, but that's life I'm afraid).
Switching between local queue managers is fine, but switching between remote queue managers eventually gives MQRC_Q_MGR_NOT_AVAILABLE (2059) on the connect. On the remote queue manager, doing netstat -an shows loads of active connections on the QM port. It looks like disconnecting and closing the queue manager doesn't release the TCP connection. I've tried setting KeepAlive=yes on the ports on the QM, but this doesn't seem to make any difference. Stopping the app and restarting allows me to reconnect to the remote queue manager, but eventually, I get MQRC_Q_MGR_NOT_AVAILABLE again. Therefore, it looks like the MQQueueManager object isn't cleaning up properly or I'm not correctly disposing of the object. MQQueueManager doesn't implement IDisposable, so I can see no way to force it to clean up.
A simplied code snippet follows:-
Code: |
MQQueueManager MQMgr = null;
MQQueue MQ = null;
while (!Bored)
{
MQEnvironment.Hostname = Host;
MQEnvironment.Port = Port;
MQEnvironment.Channel = Channel;
MQMgr = new MQQueueManager();
MQMgr.Connect();
MQ = MQMgr.AccessQueue(QueueName, Options);
// Do some stuff...
...
MQMgr.Disconnect();
MQMgr.Close(); // Is this necessary ??
MQMgr = null; // Destroy object
}
|
Client and server both running MQ 5.3 + CSD 7 on WinXP.
To be honest, I can live with each instance of this app only handling one queue manager, but I'm concerned even with a single queue manager that resources may be eaten. For instance, if a connection is lost, so needs to be retried, would I still eventually run out of TCP connections? Am I doing something fundamentally wrong in my code or is this a restriction of the .NET classes for MQ?
Thanks, Doug |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Mar 03, 2005 9:04 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I've run into this problem with Java as well. It seems to take a period of time between when the connection object is closed/disconnected and when the client channel actually ends.
The best solution, from a purely application point of view, is to make your .NET app a pure client application, and have it establish a pool of connections to all of your queue managers at startup, and close them all at shutdown.
Rapid connect/disconnects is resource intensive anyway. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
doug |
Posted: Fri Mar 04, 2005 12:35 am Post subject: |
|
|
Novice
Joined: 27 May 2003 Posts: 11
|
Is it possible to keep a pool of queue manager connections in one thread ? I thought you were limited to one active connection. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Mar 04, 2005 5:18 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'm not going to commit to it being possible to do in a single thread - particularly in .NET (which I don't know very well at all).
But there ARE differences between client connections and server connections, in terms of thread level stuff.
Try it and see what happens...
I probably actually know the answer to this... but not right now. Maybe after the coffee kicks in. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
doug |
Posted: Fri Mar 04, 2005 5:20 am Post subject: |
|
|
Novice
Joined: 27 May 2003 Posts: 11
|
Thanks - I'll have a play |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|