Posted: Tue May 27, 2003 12:47 am Post subject: MQ .NET - Disconnecting from a Queue Manager
Novice
Joined: 27 May 2003 Posts: 11
I'm a bit confused how to disconnect from a queue manager so that I can connect to another in a single threaded program. If I try:-
MQQueueManager mqMgr;
...
mqMgr = new MQQueueManager("OldMgr");
mqMgr.Connect("OldMgr");
mqMgr.Disconnect();
mqMgr.Connect("NewMgr");
... mqMgr.Name is still "OldMgr". OK...this figures - an MQQueueManager instance is associated with a given queue manager and this can't be changed. So now the problem is how to delete the instance.
mqMgr = new MQQueueManager("OldMgr");
mqMgr.Connect("OldMgr");
mqMgr.Disconnect();
mqMgr = null;
mqMgr = new MQQueueManager("NewMgr");
mqMgr.Connect("NewMgr");
Well this appears to work but it worries me as resources won't get freed until the GC gets round to it. Won't there be the possiblilty of getting an "Already connected" error here?
The Close() method is a bit of a tease and might be what I want, however:-
mqMgr = new MQQueueManager("OldMgr");
mqMgr.Connect("OldMgr");
mqMgr.Disconnect();
mqMgr.Close();
mqMgr = null;
mqMgr = new MQQueueManager("NewMgr");
mqMgr.Connect("NewMgr");
The Close always fails with MQRC_HCONN_ERROR. How am I supposed to use this (and what does it do?). What is the recommended way of closing a connection and opening a new one?
As an aside, is the Connect() method completely redundant? I (wrongly) made the assumption that if you didn't specify a queue manager name on the constructor then no connection is made until Connect(Name) was made. However you do this, you just end up with a connection to the default queue manager and Connect doesn't seem to do anything at all.
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