Solved

Graceful shutdown of Axis web service?

Posted on 2004-08-03
8
502 Views
Last Modified: 2012-05-05
I have a web service deployed using Axis in JBOSS 3.2.1.  The service uses a class, SocketConnection, which has a static reference to a socket which always remains open.   I need to gracefully close this socket if the JBOSS server is brought down.  I tried adding a finalize method to the SocketConnection class but it isn't getting invoked.  Does anyone know how I can accomplish this?  Again, I have the classes deployed using Axis as defined in the wsdd file.
0
Comment
Question by:wmiddle
8 Comments
 
LVL 1

Expert Comment

by:wolfc
ID: 11709967
Why close gracefully?

I have a SOAP service deployed using WSDP instead of Axis. If JBoss is shutting down something serious is going on, so it may go down in flames as far as I care.
0
 

Author Comment

by:wmiddle
ID: 11710002
Actually the shutdown will be intentional
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11710269
In a thread try to connect to the JBoss service. If it is not connected by thread then code your logic to shutdown ur service. Instead of checking wither JBoss service is existing or not at certain time intervals check for this. So it will not given burden to ur service aswell ur server.

Regards
Sudhakar
0
 
LVL 92

Expert Comment

by:objects
ID: 11710465
> Actually the shutdown will be intentional

The close the socket when the shutdown is initiated.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:wmiddle
ID: 11710971
>> In a thread try to connect to the JBoss service. If it is not connected by thread then code your logic to shutdown ur service

By the time the JBoss service is shut down I won't be able to shutdown my service.  The JVM will have exited by then

>> The close the socket when the shutdown is initiated
The shutdown is not initiated by the application.  it is someone hitting ctrl-C in the Jboss window

Aren't there any hooks into the shutdown sequence similar to a finalize method?  

Worst case scenario is I can provide a web method to shut down the socket connection and write a page or app that the operator would need to use before bringing down Jboss.  This wouldn't help with an unexpected or unplanned shutdown of Jboss.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 11710997
> it is someone hitting ctrl-C in the Jboss window

trap ctrl-c and do the shutdown

> Aren't there any hooks into the shutdown sequence similar to a finalize method?

Runtime.addShutdownHook()
0
 

Author Comment

by:wmiddle
ID: 11711360
// In constructor of SocketConnection
SocketCloser closer = new SocketCloser(this);
Thread closerThread = new Thread(closer);
Runtime.getRuntime().addShutdownHook(closerThread);

// SocketCloser class
public class SocketCloser implements Runnable
{
      SocketConnection connection = null;

  public SocketCloser(SocketConnection connection)
  {
      super();
      this.connection = connection;
  }
  public void run()
  {
      connection.shutDown();      
  }
}
0
 
LVL 92

Expert Comment

by:objects
ID: 11711543
glad i could help :-)

http://www.objects.com.au/staff/mick
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
where is session ID cache stored 1 46
topping3 challenge 14 69
PDFBox - convert image to PDF, PDF resolution 3 117
Java Jpanels and Jframe 8 28
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now