[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 555
  • Last Modified:

Graceful shutdown of Axis web service?

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
wmiddle
Asked:
wmiddle
1 Solution
 
wolfcCommented:
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
 
wmiddleAuthor Commented:
Actually the shutdown will be intentional
0
 
sudhakar_koundinyaCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
objectsCommented:
> Actually the shutdown will be intentional

The close the socket when the shutdown is initiated.
0
 
wmiddleAuthor Commented:
>> 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
 
objectsCommented:
> 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
 
wmiddleAuthor Commented:
// 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
 
objectsCommented:
glad i could help :-)

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now