jBilling计划的插件错误:无法安排可插入任务

时间:2013-10-28 13:05:10

标签: java plugins billing

我在尝试开发最简单的jBilling预定插件时遇到了一个奇怪的问题。 我想制作一个每分钟都会执行的插件,但会运行一段时间。我这样理解jBilling将如何以这种方式运行 - 只运行一个插件实例或每分钟启动一个新实例。所以我编写了插件(见下文),并用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!");
        }
    }
}

`

3 个答案:

答案 0 :(得分:0)

Jbilling可插拔任务意味着由JBilling系统本身处理,您不需要提供调度程序行为。您需要做的只是在Configuration菜单中编写任务(自定义类)配置并在表中插入条目。

当您想要创建Task时,您需要扩展/实现PlugableTask并需要在plugabletaskparameter表中指定具有正确类别类型的类名,例如:如果您要创建付款任务,类别类型是6

答案 1 :(得分:0)

使用5参数cron表达式时,我们还遇到了“无法安排可插拔任务”错误。更改为6参数表达式对我们有用,并允许安排任务。

例如,要安排每分钟我们会使用“0 * * * *?”而不是“0 * * * *”。

答案 2 :(得分: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;
    }
}