0

最も単純な 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!");
        }
    }
}

`

4

3 に答える 3

0

また、5 引数の cron 式を使用すると、「プラグ可能なタスクのスケジュールに失敗しました」というエラーが発生しました。6 引数の式に変更するとうまくいき、タスクをスケジュールできるようになりました。

たとえば、毎分スケジュールするには、「0 * * * * ?」を使用します。「0 * * * *」ではなく。

于 2014-09-08T08:16:02.053 に答える
0

Jbilling のプラグ可能なタスクは、JBilling システム自体によって処理されるため、スケジューラの動作を提供する必要はありません。あなたがする必要がある唯一のことは、構成メニューでタスク(カスタムクラス)構成を記述し、テーブルにエントリを挿入することです。

Task を作成する場合は、PlugableTask を拡張/実装する必要があり、plugabletaskparameter適切なカテゴリ タイプを使用してテーブルにクラス名を指定する必要があります。たとえば、支払いタスクを作成する場合、カテゴリ タイプは 6 です。

于 2013-11-26T19:33:57.400 に答える
0
try this

package com.sapienter.jbilling.server.pluggableTask;

import com.sapienter.jbilling.server.pluggableTask.admin.PluggableTaskException;
import com.sapienter.jbilling.server.process.task.AbstractBackwardSimpleScheduledTask;
import org.apache.log4j.Logger;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SimpleTrigger;

import java.util.Calendar;
import java.util.concurrent.atomic.AtomicBoolean;

public class TutorialSimpleScheduledTask extends AbstractBackwardSimpleScheduledTask {
    private static final Logger LOG = Logger.getLogger(TutorialSimpleScheduledTask.class);
    private static final AtomicBoolean running = new AtomicBoolean(false);

    public String getTaskName() {
        return "Tutorial Simple Scheduled Task: " + getScheduleString();
    }

    public void execute(JobExecutionContext context) throws JobExecutionException {
        super.execute(context);//_init(context);

        if (running.compareAndSet(false, true)) {
            LOG.debug("SimpleScheduledTask is running - " + Calendar.getInstance().getTime());
            running.set(false);
        } else {
            LOG.warn("Failed to trigger tutorial simple process at " + context.getFireTime()
                    + ", another process is already running.");
        }
    }

    /**
     * Returns the scheduled trigger for the mediation process. If the plug-in is missing
     * the {@link com.sapienter.jbilling.server.process.task.AbstractSimpleScheduledTask}
     * parameters use the the default jbilling.properties process schedule instead.
     *
     * @return mediation trigger for scheduling
     * @throws com.sapienter.jbilling.server.pluggableTask.admin.PluggableTaskException
     *          thrown if properties or plug-in parameters could not be parsed
     */
    @Override
    public SimpleTrigger getTrigger() throws PluggableTaskException {
        SimpleTrigger trigger = super.getTrigger();

        // trigger start time and frequency using jbilling.properties unless plug-in
        // parameters have been explicitly set to define the mediation schedule
        if (useProperties()) {
            LOG.debug("Scheduling tutorial process from jbilling.properties ...");
            trigger = setTriggerFromProperties(trigger);
        } else {
            LOG.debug("Scheduling tutorial process using plug-in parameters ...");
        }

        return trigger;
    }
}
于 2014-12-02T14:17:50.540 に答える