Monitoring processes in GWT

Does anyone know how to keep track of long running server processes in GWT other than polling the server? We need to do some cumbersome multi-step processing related to I / O on the server, and it would be nice to display the progress of this processing in the browser.

+1


source to share


2 answers


This is pretty easy to handle in GWT.

A long running process is started by a GWT RPC call, in which case you have an entry point or not, in which case you need to manually start that.

Remember, GWT RPC calls are asynchronous, so they don't need to return immediately. You need an RPC call for example checkStatus()

. This way 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);

      

It may take your server as long as it likes (within reason) to return with checkStatus (). It can return because the job is in progress or simply with an update of the job status. The above will continue until the job completion flag is set.

+3


source


I think it depends on your process, but if you are going to do something like streaming data, you can use the Push (or Comet) server technique. GWT supports Comet implementation. google GWT + Comet, or GWT + COMET + Tomcat, I read about comets and gwt in Google Web Toolkit Applications (gwtapps.com).



0


source







All Articles