PersistJobDataAfterExecution注解

2022-11-10 14:25:08 浏览数 (1)

心地善良的人、富于幻想的人比冷酷残忍的人更容易聚合——约翰逊

quartz之前我们也聊过了,今天说下这个注解org.quartz.PersistJobDataAfterExecution

一般和DisallowConcurrentExecution搭配使用

PersistJobDataAfterExecution表示Job执行结束后更新JobDataMap

DisallowConcurrentExecution表示不允许并发执行

代码语言:javascript复制
@Slf4j
@DisallowConcurrentExecution
@PersistJobDataAfterExecution
public class SettlementJob implements Job {

    /**
     * <p>
     * Called by the <code>{@link Scheduler}</code> when a <code>{@link Trigger}</code>
     * fires that is associated with the <code>Job</code>.
     * </p>
     *
     * <p>
     * The implementation may wish to set a
     * {@link JobExecutionContext#setResult(Object) result} object on the
     * {@link JobExecutionContext} before this method exits.  The result itself
     * is meaningless to Quartz, but may be informative to
     * <code>{@link JobListener}s</code> or
     * <code>{@link TriggerListener}s</code> that are watching the job's
     * execution.
     * </p>
     *
     * @param context 上下文
     * @throws JobExecutionException if there is an exception while executing the job.
     */
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        final JobDetail jobDetail = context.getJobDetail();
        final JobDataMap jobDataMap = jobDetail.getJobDataMap();
        log.info(jobDetail.getKey().getName()   "执行了");
    }
}

0 人点赞