Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Graceful shutdown of Axis web service?

Posted on 2004-08-03
8
518 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

791 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