PDA

View Full Version : Best practice for kicking off and monitoring a long-running process over RPC



pjaromin
29 Oct 2009, 1:48 PM
I posted this on the GWT group, but thought that maybe there was something in GXT specifically to assist with this -- so I hope you don't mind the post here as well.

I'm writing a remote service that executes a long-running process that I'm updating on the client-side using a progress bar widget.

What I'd like to do is have two methods in the service:

String longRunningProcess(Request request);

Progress checkProgress(String id);

The question is, what's the best way to get the ID back to the client?
The UUID should be created on the server side -- but if I generate it in the "longRunningProcess" method, it won't return until AFTER the process is complete.

I currently see two options:

1) add an "primeProcess" method to the service that simply returns the next UUID. This UUID is provided by the client in the request.

2) Have the client generate the UUID...but the server really should be the place the ID is generated, since it's managing them and can guarantee uniqueness.

Is there a better way? How do others handle this?

Thanks!

-Patrick

Martin.Trummer
30 Oct 2009, 2:00 AM
just some thoughts - I think it should be like this:


user clicks button
RPC reaches server
unique id is generated

a long running thread to do the actual work is started and this thread gets the uid


server returns uid to client




client can now periodically call another RPC (uid as parameter) to check the status of the working thread
OR if you have any server-push technology in place, the server could inform the client