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);
}