Solved

Graceful shutdown of Axis web service?

Posted on 2004-08-03
8
510 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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 92

Expert Comment

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

The close the socket when the shutdown is initiated.
0
 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

772 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