publishSync 方法只在远程文档生成完成时返回,无论生成是否成功都是如此。当该方法返回时,您可以检查结果代码以确定状态。另一个验证选项方法是使用 publish 方法,该方法是异步方法。
然后,在客户机线程中,您可以等待该线程完成并使用生成器的 getStatus 方法来检查状态。
使用 publishSync 方法:
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
使用 publish 方法:
在大部分情况下,
publishSync 方法最便捷。
publish 方法可用在客户机代码不等待作业完成时(尤其是在远程文档生成场景中),以便验证不锁定客户机应用程序。
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);
}