当前位置: 首页>>代码示例>>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;未经允许,请勿转载。