Forums Register Login

long running service call and tracking completion

+Pie Number of slices to send: Send
Hi All,

I have a servlet which talks to a web service. The web service method is representation wrapper for a batch program which could take somewhere between few hours or a day max to finish.
I had this create as an asynchronous web service call. At the end this web service updates a backend table with the status as 'COMPLETED'

But now I have to call another web service after completion of the first web service.
My question is what is the best way to keep track of the completion of a long running service in my case the first web service completion.

Should i change the asynchronous web service to synchronous mode which would mean keeping a thread open for a day or should i opt for some sort of polling service which checks for an event.

Let me know your thoughts on this.

Regards,
+Pie Number of slices to send: Send
How to do it depends on what you have running and where you want to start this second web service call. Some possibilities:

1. eMail
2. JMS - Java messaging service
3. Manage the initial request and subsequent request through a JavaSpaces server

Bill

+Pie Number of slices to send: Send
Thanks Bill.
Ideally we would want to manage the second web service call in seamless fashion. But the second web service cannot start till the first web service completes its task.

I am not conversant with Javaspaces. But with JMS i believe you mean the first web service drops a message on the Queue when it completes and the subscriber of the Queue kicks off the second web service based on the receipt of the completion message.

Can we spawn a separate runnable thread to initiate the first web service call and make the servlet spawning it wait.
After completion of this thread the servlet will trigger the second web service call.

Let me know your thoughts on the threading solution.


Regards,



+Pie Number of slices to send: Send
 

Can we spawn a separate runnable thread to initiate the first web service call and make the servlet spawning it wait.
After completion of this thread the servlet will trigger the second web service call.



No no no, you should never make a servlet request thread wait. Too many ways for things to go wrong - there should be an initial response which tells the client that the process has been started.

Instead have a web service call manager class to subscribe to the JMS and manage the whole process in a separate Thread.
Make this class independent of the servlet environment so you can test and debug. Handling all the possible errors needs to be carefully thought out.

Bill
+Pie Number of slices to send: Send
Thanks Again Bill.

Instead have a web service call manager class to subscribe to the JMS and manage the whole process in a separate Thread.



Can you confirm this understanding. Considering we have two long running web services to be run sequentially, the Web Service 1 after completion will drop a message on JMS queue and the subscriber (manager class) to this queue will trigger web service2
+Pie Number of slices to send: Send
Sounds good to me.

Make sure you provide for recording/recovery from errors and don't leave any connections open.

Repeating myself but this is important, design so that you can test the manager outside the servlet environment. A bit of extra work but you will be glad you did.

Bill
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1741 times.
Similar Threads
regarding Asynchronous request-response feature
addShutdownHook and killing a asynchronous process
Procedure and Document style messaging
Asynchronous web service
Asynchronous Web service call
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 22:15:40.