How to know if a web service is running

I have the following scenario:

  • JBoss hosts a web service.
  • The web service is used by a java application.

Now the usual startup script:

  • jBoss launches and loads a web application.
  • Then the application starts and uses the web service.

Now the problem:

If the Java application starts first, is there a way to tell the web service has started?

I thought about checking the web service regularly, but that will probably help a little overhead. Any solution is appreciated.

+3


source to share


3 answers


"Pinging" a web service regularly isn't a big overhead. Why should it be?

Wait a little between tries. The general strategy is to maximize the waiting time between attempts. For example. try, if not ready, wait 1 second, then try again and if still not ready, wait 2 seconds, then 4 seconds, etc. up to 10 seconds between attempts.

Meanwhile, show a message to the user like:

"Waiting for web service to start..."

      



Optional, including the number of attempts done like this:

"Waiting for web service to start... (retrying #2)"

      

Alternatively, you can make a small static text file available as part of the webapp, for example "ping.txt", and try to get that as your test if the application is ready and available, you don't need to call the webservice itself. It can also point to Servlet

, in which case you can make sure the servlet container is hoisted as well (disable caching of that ping url of course).

Also as another alternative, if your webservice module has a significant amount of time to get up, the "ping" target could be the web service wsdl document. Most webservice frameworks provide a way to access / load a dynamically generated web service WSDL document. If that url responds and sends back a dynamic WSDL document, the wsdl module gets up as well.

0


source


You have to constantly worry about connection problems in your client application, not just at startup, so there is no point in "pinging". This applies to any remote connection solution.

When it's time to call a service, just call it. If this happens, the connection will fail and you will be able to inform the user accordingly. You have to do this whether you ping or not, as the service might disappear between the last ping and the actual call.



The remote service can go up and down as many times as desired while the client is active.

+1


source


You can just check the logs from var / log /..../ access.log for example. tail -f / var / log / apache2 / access.log

-1


source







All Articles