當前位置: 首頁>>代碼示例>>Java>>正文


Java JobDataMap.putAsString方法代碼示例

本文整理匯總了Java中org.quartz.JobDataMap.putAsString方法的典型用法代碼示例。如果您正苦於以下問題:Java JobDataMap.putAsString方法的具體用法?Java JobDataMap.putAsString怎麽用?Java JobDataMap.putAsString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.JobDataMap的用法示例。


在下文中一共展示了JobDataMap.putAsString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.quartz.JobDataMap; //導入方法依賴的package包/類
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    final int numberOfRetries;
    JobDataMap jobDataMap = context.getMergedJobDataMap();
    numberOfRetries = jobDataMap.containsKey(NUMBER_OF_RETRIES_PARAM) ?
            jobDataMap.getIntValue(NUMBER_OF_RETRIES_PARAM) : DEFAULT_NUMBER_OF_RETRIES;
    //check if running job class has the "NonRetryable" annotation
    boolean isRetryable = jobDataMap.containsKey(Constants.JOB_DEFINITION) ?
            ((JobDefinition)jobDataMap.get(Constants.JOB_DEFINITION)).isRetryable() : true;
    try {
        job.execute(context);
        //reset retry param, just in case
        jobDataMap.putAsString(NUMBER_OF_RETRIES_PARAM, 0);
    } catch (Exception e) {
        //do not retry if job is not retryable or no more retries left
        if (!isRetryable || numberOfRetries <= 0) {
            throwAndFinish(jobDataMap, context, e);
        }
        triggerRefire(jobDataMap, numberOfRetries, context, e);
    } catch (Throwable t) {
        //do not retry on throwable
        throwAndFinish(jobDataMap, context, t);
    }
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:25,代碼來源:ErrorHandlingJob.java

示例2: triggerRefire

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private void triggerRefire(JobDataMap jobDataMap, int numberOfRetries, JobExecutionContext context, Throwable t)
        throws JobExecutionException {
    final long sleepTimeBetweenRetries = jobDataMap.containsKey(SLEEP_TIME_BETWEEN_RETRIES_PARAM) ?
            jobDataMap.getLongValue(SLEEP_TIME_BETWEEN_RETRIES_PARAM) : DEFAULT_SLEEP_TIME_BETWEEN_RETRIES;
    try {
        Thread.sleep(sleepTimeBetweenRetries);
    } catch (InterruptedException e) {}
    context.put(Constants.JOB_EXCEPTION, t);
    jobDataMap.putAsString(NUMBER_OF_RETRIES_PARAM, --numberOfRetries);
    //set refire flag as true
    throw new JobExecutionException(t, true);
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:13,代碼來源:ErrorHandlingJob.java

示例3: throwAndFinish

import org.quartz.JobDataMap; //導入方法依賴的package包/類
private void throwAndFinish(JobDataMap jobDataMap, JobExecutionContext context, Throwable t)
        throws JobExecutionException {
    context.put(Constants.JOB_EXCEPTION, t);
    //reset retry param, just in case
    jobDataMap.putAsString(NUMBER_OF_RETRIES_PARAM, 0);
    JobExecutionException e = new JobExecutionException("This trigger has thrown a terminal exception. " +
            "Retries exceeded or job not retryable", t);
    throw e;
}
 
開發者ID:taboola,項目名稱:taboola-cronyx,代碼行數:10,代碼來源:ErrorHandlingJob.java


注:本文中的org.quartz.JobDataMap.putAsString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。