Waiting for a result (Java)

To find out, what is the status of the submission, you can call getStatus every 10 seconds, which provides you with the current state and eventually a progress indicator or an error message depending on the state.

The following table shows the Status object fields for the different states:

State value State Progress Report
50Waiting in queuePosition in queue, 0 being next in queue-
100ParsingPercentage of completion-
200ComparingPercentage of completion-
230Generating result files--
250Packaging result--
300Done, result ready for download--
400General error-Details
401Bad language-Details
402Not enough submissions-Details
403Submission aborted-Details

So waiting for the result can be done in a simple loop like this:

        Status status;
        try {
            while(true) {
                status = stub.getStatus(submissionID);
                 * Here you could print out more details about the status of
                 * the submission, but it's left out here... 
                if(status.getState() >= JPLAG_DONE) break;
                Thread.sleep(10000);    // wait 10 seconds
                System.out.print(".");  // tell user something's happening
            if(status.getState() >= JPLAG_ERROR) {
                 * An error occurred: Print out error message and acknowledge
                 * error by cancelling the submission
                System.out.println("\nSome error occurred: "
                    + status.getReport());
                return false;
        catch(Exception e) {
            return false;
        return true;

Note that you have to acknowledge an error by cancelling the submission with cancelSubmission to have it removed from the server.

Next: Receiving a result

Last modified 5 years ago Last modified on Dec 7, 2012 11:16:34 AM