Does anyone know how to monitor long-running server-side processes in GWT, other than polling the server? We need to do some time-consuming, multiple-step, I/O-bound processing on the server, and it would be nice to display the progress of this processing in the browser.
I think it depends on your process but if you are going to do something like Data Streaming you can use Server Push (Or Comet) technic.GWT supports Comet implementation. google GWT+Comet ,or GWT+COMET+Tomcat,i read about comet and gwt in "Google Web Toolkit Applications" Book(gwtapps.com).
This is fairly easy to handle in GWT.
The long-running process is either triggered by a GWT RPC call, in which case you have your entry point, or it isn't, in which case you need to start this off manually.
Remember that GWT RPC calls are asynchronous so they don't need to return immediately. You need an RPC call like checkStatus()
. So you can do things like:
public class JobStatus {
private boolean done;
// other info
// ...
}
public class JobStatusCallback<JobStatus> extends AsyncCallback {
public final void onSuccess(JobStatus result) {
if (result.isDone()) {
done();
} else {
checkAgain();
}
}
public final void onFailure(Throwable caught) {
error(caught);
checkAgain();
}
public void done() { // override
}
public void checkAgain() {
service.checkStatus(this);
}
public void error(Thorwable t) { // override
}
});
and in your RPC service:
void checkStatus(AsyncCallback<JobStatus> callback);
Your server can take as long as it likes (within reason) to return from checkStatus(). It can return because the job is done or just with a job status update. The above will continue looping until the job status done flag is set.