Author |
Message
|
tapak |
Posted: Thu Nov 02, 2006 2:41 pm Post subject: How to disconnect gracefully on killing a Java Application |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
Is there a way to disconnect from MQ on killing the Java standalone application in Unix . When I kill a Java client application connecting to MQ ( using kill command in unix ) , the server connection channels still seems to be running. Is there a way to disconnect from MQ gracefully on killing the process.
Does the finalize method serve the purpose.? |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 02, 2006 3:48 pm Post subject: Re: How to disconnect gracefully on killing a Java Applicati |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
tapak wrote: |
Is there a way to disconnect from MQ on killing the Java standalone application in Unix . When I kill a Java client application connecting to MQ ( using kill command in unix ) , the server connection channels still seems to be running. Is there a way to disconnect from MQ gracefully on killing the process.
Does the finalize method serve the purpose.? |
If the JVM does a graceful shutdown the finalize method may be used to clean up all outstanding resources.
The proper way of your application should be to only keep the resource as long as it is truely needed, and to allow for some graceful shutdown...
If you need to kill -9 the JVM the only way to kill the resource is by checking the qmgr:
see queue status and display connection.
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
tapak |
Posted: Fri Nov 03, 2006 6:45 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
Hi fjb_saper,
Thanks for the info. You have explanations for all my problems with mq and Java. You are the best. |
|
Back to top |
|
 |
tapak |
Posted: Fri Nov 03, 2006 7:02 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
Is there a way to gracefully shutdown the JVM for a standalone application. |
|
Back to top |
|
 |
fjb_saper |
Posted: Fri Nov 03, 2006 2:48 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
tapak wrote: |
Is there a way to gracefully shutdown the JVM for a standalone application. |
Code: |
System.exit(0); //from memory |
But before calling this snippet I would try to clean up all resources  _________________ MQ & Broker admin |
|
Back to top |
|
 |
JLRowe |
Posted: Wed Nov 08, 2006 3:03 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
Yes, the return statement!
tapak wrote: |
Is there a way to gracefully shutdown the JVM for a standalone application. |
|
|
Back to top |
|
 |
tapak |
Posted: Wed Nov 08, 2006 8:38 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
Sorry. I didnt made my question clear.
I am having a standalone java application started as a background process in Unix which listens to a queue . Is there a way to stop the application other than using kill -9 which will gracefully shutdown the JVM. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Nov 08, 2006 9:37 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Yes.
Write your program to accept a message that tells it to gracefully shut down. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
tapak |
Posted: Wed Nov 08, 2006 10:59 am Post subject: |
|
|
 Centurion
Joined: 26 Oct 2005 Posts: 149 Location: Hartford,CT
|
Thanks Jeff. That is a great idea. |
|
Back to top |
|
 |
|