How to build a time-consuming web service

a simple and theoretical question, the answer is probably one, but I would like to listen to some opinions and suggestions. I need a web services implementation (in java) that will start a time consuming process that will parse some input file and work with dome db.

What is the best approach that allows the user to know that the whole process has not only begun, but has come to an end, with parsing, updating db ...? Because I cannot hang a user waiting for the completion of the whole process.

Note. Before starting the process, the user is authenticated.

EDIT: access to a web service is provided not only through a web browser, but clients can also access it with any client created with the language they need if they refer to wsdl.

thanks

+4
source share
2 answers

In your scenario, you must implement asynchronous web services. With asynchronous web services, you have two options.

  • (as mentioned earlier) you can query the service to see if the process is complete.
  • You can request a server for callback

The first approach is easy to implement, and it will work with many WS libraries. However, this is due to the lack of your server, which should waste bandwidth on client polling requests. After all, this is a survey. and in most cases, polling is a bad idea.

The latter would not be as simple as the previous one. And you do not know if each JAX-WS library supports. To support you, I quickly looked at Google and found this link.

http://www.developer.com/java/web/article.php/3863416/Using-Axis2-and-Java-for-Asynchronous-Web-Service-Invocation-on-the-Client-Side.htm

This may help you a bit.

+6
source

I would give the user a token when they sent the data and asked them to poll (asynchronously) another method with their token.

Then, in method 1, I would add data to the queue, and another process running on the server checked this queue and performed the processing. Then update the token in the database to notify the user of the completion of work.

I have already worked on such things, and found that disabling a lengthy process on an HTTP / web based system is a bad idea, since base systems can often turn off calls to webservice that have been running for a long time.

+4
source

All Articles