Verifying document generation success

The publishSync method returns only when the remote document generation completes, whether the generation is successful or not. When that method returns, you can check the result code to determine the status. Another verification option way is to use the publish method which is asynchnorous. Then, in the client thread, you can wait until the thread is finished and check the status by using the getStatus method of the generator.

Using the publishSync method:

   RRDGEngine.EngineStatus status = generator.publishSync(docSpec, previewQueryLimit);
   // At this point all is done ( successfully or not) and the job status  is in the status variable

Using the publish method:

In most cases, the publishSync method is the most convenient method. The publish method can be used when the client code does not wait for the job to finish, especially in the remote document generation scenario, so that the verification does not lock the client application.
For asynchronous jobs the flow is:
  • Start job
  • Poll the job periodically to see if it finished
        Thread t = generator.publish(docSpec, previewQueryLimit);
        // this reeturns almost immediately and at this point the docgen is usually still running so the client code needs to wait for it

        // wait for the job to finish
        try
        {
            t.join();

            // here the job is finished and it status can be obtaine with
            RRDGEngine.EngineStatus status = generator.getStatus();
        }
        catch (InterruptedException e)
        {
            throw new RPEException(e);
        }

Feedback