File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes wait() in web services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "wait() in web services" Watch "wait() in web services" New topic
Author

wait() in web services

Rafael Z. Frantz
Greenhorn

Joined: Mar 09, 2010
Posts: 20
Hi all!

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!
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
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.
Best wishes!
Rafael Z. Frantz
Greenhorn

Joined: Mar 09, 2010
Posts: 20
Hi Ivan!

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?

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: wait() in web services