2013-10-28 2 views
0

가장 간단한 jBilling 예약 플러그인을 개발하는 중 이상한 문제가 있습니다. 매분 실행되는 플러그인을 만들고 싶지만 더 오랜 시간 실행됩니다. 이 방법으로 jBilling이 작동하는 방식을 이해할 수 있었지만 플러그 인의 단일 인스턴스 만 실행하거나 매분마다 새 인스턴스를 시작할 수있었습니다. 그래서 플러그인 (아래 참조)을 작성하고 cron_exp = "* * * * "으로 설치했습니다 (" 0-23 * * *"및 기타 변형). 로그에 jBilling가 시작되면 하지만 지금, 나는 다음과 같은 한 오류 :jBilling scheduled plugin error : pluggable task를 스케쥴하지 못했습니다.

2013-10-28 16:28:26,215 DEBUG [com.sapienter.jbilling.server.pluggableTask.admin.PluggableTaskManager] Applying task com.sapienter.jbilling.server.MyPlugins.testLongTimeRunningPlugin 2013-10-28 16:28:26,217 DEBUG [com.sapienter.jbilling.server.pluggableTask.admin.PluggableTaskManager] Creating a new instance of com.sapienter.jbilling.server.MyPlugins.testLongTimeRunningPlugin 2013-10-28 16:28:26,225 WARN [com.sapienter.jbilling.server.util.Bootstrap] Failed to schedule pluggable task [com.sapienter.jbilling.server.MyPlugins.testLongTimeRunningPlugin] 2013-10-28 16:28:26,225 DEBUG [com.sapienter.jbilling.server.util.Bootstrap] Starting the job scheduler

따라서는 예약 할 수없는 이유를 궁금해하고 내가 그것을 어떻게 해결할 수 있습니까? 다음은 코드입니다, 플러그 인 작업을 Jbilling

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

`

답변

0

가 JBilling 시스템 자체에 의해 핸들을 의미한다, 당신은 스케줄러 동작을 제공 할 필요 없어요. 해야 할 일은 Configuration 메뉴에서 task (custom class)를 작성하고 테이블에 항목을 삽입하는 것입니다.

Task를 생성하려면 PlugableTask를 확장/구현하고 plugabletaskparameter 테이블의 클래스 이름을 적절한 카테고리 유형과 함께 지정해야합니다 (예 : 지불 작업을 생성하려는 경우 카테고리 유형 is 6

0

5 인수 cron 식을 사용할 때 "플러그 가능 작업을 예약하지 못했습니다"오류가 발생했습니다. 6 인자 표현식으로 바꾸면 우리를 위해 일했고 작업 일정을 잡을 수있었습니다.

예를 들어 매분을 계획하려면 "0 * * * *?"을 사용하십시오. "0 * * * *"보다는 오히려.

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; 
    } 
} 
관련 문제