ru.tinkoff.kora.scheduling.quartz.KoraQuartzJob Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scheduling-quartz Show documentation
Show all versions of scheduling-quartz Show documentation
Kora scheduling-quartz module
package ru.tinkoff.kora.scheduling.quartz;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Trigger;
import org.slf4j.MDC;
import ru.tinkoff.kora.common.Context;
import ru.tinkoff.kora.scheduling.common.telemetry.SchedulingTelemetry;
import java.util.function.Consumer;
public abstract class KoraQuartzJob implements Job {
private final Consumer job;
private final Trigger trigger;
private final SchedulingTelemetry telemetry;
public KoraQuartzJob(SchedulingTelemetry telemetry, Consumer job, Trigger trigger) {
this.job = job;
this.trigger = trigger;
this.telemetry = telemetry;
}
@Override
public final void execute(JobExecutionContext jobExecutionContext) {
MDC.clear();
Context.clear();
var ctx = Context.current();
var telemetryCtx = this.telemetry.get(ctx);
try {
this.job.accept(jobExecutionContext);
telemetryCtx.close(null);
} catch (Throwable e) {
telemetryCtx.close(e);
throw e;
}
}
public Trigger getTrigger() {
return this.trigger;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy