I am currently coding a Java WebService using axis2. However, one particular request needs me to do constant polling a status in another server for around 3-10 seconds time.
I want to use Thread.sleep to do polling like every 500 mili for 3 seconds. Does it have any implication like performance issue or can anyone suggest a better idea?
EDIT
My architecture is like this
Client <—> axis2 <—> server polling for 3-10 seconds
There are a number of different options:
If you can change the client, then it may be a good idea to move the wait into the client. This means that the server doesn’t have loads of threads hanging around.
So you would have two web services, one to initialise the request, the second to get the result. The client (not the axis server) would call the first web service, and then the second possibly multiple times.
This has the advantage that you don’t have to do any work with threads in the server (which simplifies life a lot). The thread code is in the client.
If you do end up doing a sleep in your server, make sure you have enough threads, if you’re using Tomcat, see Best practices for configuring Apache / Tomcat