ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ API Support » Disconnect();

Post new topic  Reply to topic
 Disconnect(); « View previous topic :: View next topic » 
Author Message
dahacker
PostPosted: Mon Jul 25, 2005 7:06 am    Post subject: Disconnect(); Reply with quote

Newbie

Joined: 20 Jul 2005
Posts: 5

per the examples in MQ manuals, every time I want to Put(), I:

new MQManager();
.
.
.
Put();
Close();
Disconnect();

1. What happens if I do not Disconnect()? Is that MQ reource lost? When does MQ decide that the transaction regarding that resource has timed out and free it up again?

2. Can calls to Close() and Diconnect() raise exceptions?

Thanks,
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Jul 25, 2005 7:18 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If you have more than one PUT to do, you should do them all. Only Close and Disconnect when your program is ending, or you have received an error of some kind.

Yes, Close() and Disconnect() can throw errors. The most frequently encountered ones have to do with trying to close or disconnect handles that are already closed/disconnected or have gone out of scope.

The default transaction handling is somewhat platform dependant (at a minimum, z/OS is different than distributed), and is documented.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
dahacker
PostPosted: Mon Jul 25, 2005 9:10 am    Post subject: Reply with quote

Newbie

Joined: 20 Jul 2005
Posts: 5

You say "if you have more han one Put to do, you should do them all." So for every Put(), i need to invoke a new QueueManager? But I only need to Close and Disconnect once (when exiting or dealing with an error)?

Let's say I Close() and Disconnect() only when my application terminates or traps an exception. Because my app never terminates, and assuming I don't get any exceptions. Let's say my app terminates uncleanly and never called the Disconnect(). I then restart it. Assume this happens several times. What happens on the MQ side? Is that resource lost until I restart MQ?

I know I have finite MQ channels.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Jul 25, 2005 9:16 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

dahacker wrote:
You say "if you have more han one Put to do, you should do them all." So for every Put(), i need to invoke a new QueueManager? But I only need to Close and Disconnect once (when exiting or dealing with an error)?


No.

dahacker wrote:
Let's say I Close() and Disconnect() only when my application terminates or traps an exception. Because my app never terminates, and assuming I don't get any exceptions.

Then only open a connection when your app starts up.

dahacker wrote:
Let's say my app terminates uncleanly and never called the Disconnect(). I then restart it. Assume this happens several times. What happens on the MQ side? Is that resource lost until I restart MQ?

I know I have finite MQ channels.


Pretend MQ is a database. Write your code to handle MQ's connections the same way you would a database... In a long running program, would you estabish and then disconnect a database connection for every Select/Insert/Update/Delete? I hope not...

What happens when your program dies without explicitly calling MQDisconnect depends on the language and the environment the code is running in and exactly how hard it dies...

Generally, though, if a process goes away completely, MQ will close the connection.

The Application Programming Guide and the AP Reference have a lot of good information on this stuff.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Disconnect();
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.