最も単純な jBilling スケジュール プラグインを開発しようとしているときに、奇妙な問題が発生しました。毎分実行されるが、より長時間実行されるプラグインを作成したいと考えています。jBilling がこのようにどのように動作するかを理解するために、これが必要です - プラグインのインスタンスを 1 つだけ実行するか、毎分新しいインスタンスを開始します。そこで、プラグインを作成し (以下を参照)、cron_exp = "* * * * " でインストールしました(" 0-23 * * *" やその他のバリアントも試しました)。しかし今、jBilling を開始すると、ログに次のエラーが表示されます。
2013-10-28 16:28:26,215 DEBUG [com.sapienter.jbilling.server.pluggableTask.admin.PluggableTaskManager] 適用タスク com.sapienter.jbilling.server.MyPlugins.testLongTimeRunningPlugin 2013-10-28 16:28:26,217 DEBUG [com.sapienter.jbilling.server.pluggableTask.admin.PluggableTaskManager] com.sapienter.jbilling.server.MyPlugins.testLongTimeRunningPlugin 2013-10-28 16:28:26,225 WARN [com.sapienter.jbilling.server の新しいインスタンスを作成しています.util.Bootstrap] プラグ可能なタスクのスケジュールに失敗しました [com.sapienter.jbilling.server.MyPlugins.testLongTimeRunningPlugin] 2013-10-28 16:28:26,225 DEBUG [com.sapienter.jbilling.server.util.Bootstrap] ジョブの開始スケジューラー
では、なぜスケジュールできないのか、どうすれば修正できるのでしょうか? コードは次のとおりです。
public class testLongTimeRunningPlugin extends AbstractCronTask {
public static final String taskName = testLongTimeRunningPlugin.class.getCanonicalName();
private static final Logger LOG = Logger.getLogger(draftAPIgetProductCategories.class);
private static final int time = 5;
@Override
public String getTaskName() {
return taskName;
}
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
LOG.debug("Starting and waiting for " + time + " minutes");
try{
TimeUnit.MINUTES.sleep(time);
LOG.debug("Completed");
}catch (InterruptedException e){
LOG.debug("Interrupted!");
}
}
}
`