I have a web service that access a resource which may take time to give it an answer, so I am planing to call wait() on this web service till the response is ready, then call notify() to make it work again and finish its execution. Is is possible?
Thanks a lot!
Joined: Oct 04, 2006
Yes, I see nothing that stops you from doing that.
However, you do not say much about what kind of resource it is and the approximate time it require to produce a response.
If your web service is made to wait for a longer time and there are a lot of requests, the server may run out of resources which will cause subsequent requests to the web service to fail.
You may want to consider implementing an asynchronous web service that returns its result using, for instance, a callback.
Rafael Z. Frantz
Joined: Mar 09, 2010
Actually I could call wait() on this WS and lock it in another object (OBJ2) that I've exported to the RMI registry, so when this OBJ2 receives a notification then it invokes notifyAll(). The problem here is that the OBJ2 is copied by the JVM when exported to the RMI registry, so the object that is exported is different from the OBJ2 and looses the lock. In this case the lock remains with the true OBJ2 at the heap of the JVM. is there any way to invoke notifyAll() or notify() from an object that is inside RMI registry so that objects in the heap of the JVM can be activated?