Skip to content

Commit

Permalink
Quartz - replace Arc.container() with Instance<UserTransaction>
Browse files Browse the repository at this point in the history
- so that the UserTransaction is not removed if no other injection point
exists
  • Loading branch information
mkouba committed Nov 10, 2020
1 parent 53a8784 commit cc04d50
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.parser.CronParser;

import io.quarkus.arc.Arc;
import io.quarkus.arc.InstanceHandle;
import io.quarkus.runtime.StartupEvent;
import io.quarkus.scheduler.Scheduled;
import io.quarkus.scheduler.Scheduled.ConcurrentExecution;
Expand Down Expand Up @@ -79,7 +77,8 @@ org.quartz.Scheduler produceQuartzScheduler() {
}

public QuartzScheduler(SchedulerContext context, QuartzSupport quartzSupport, Config config,
SchedulerRuntimeConfig schedulerRuntimeConfig, Event<SkippedExecution> skippedExecutionEvent, Instance<Job> jobs) {
SchedulerRuntimeConfig schedulerRuntimeConfig, Event<SkippedExecution> skippedExecutionEvent, Instance<Job> jobs,
Instance<UserTransaction> userTransation) {
enabled = schedulerRuntimeConfig.enabled;
if (!enabled) {
LOGGER.info("Quartz scheduler is disabled by config property and will not be started");
Expand All @@ -92,10 +91,10 @@ public QuartzScheduler(SchedulerContext context, QuartzSupport quartzSupport, Co
Map<String, ScheduledInvoker> invokers = new HashMap<>();
UserTransaction transaction = null;

try (InstanceHandle<UserTransaction> handle = Arc.container().instance(UserTransaction.class)) {
try {
boolean manageTx = quartzSupport.getBuildTimeConfig().storeType.isNonManagedTxJobStore();
if (manageTx && handle.isAvailable()) {
transaction = handle.get();
if (manageTx && userTransation.isResolvable()) {
transaction = userTransation.get();
}
Properties props = getSchedulerConfigurationProperties(quartzSupport);

Expand Down

0 comments on commit cc04d50

Please sign in to comment.