From 475164cc1db8cdfa021330a5a6c912ef6e5c64e9 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti Date: Wed, 22 Nov 2023 13:47:05 +0100 Subject: [PATCH] [JBPM-10088] Do not create transaction for regular timer task --- .../jbpm/services/ejb/timer/EJBTimerScheduler.java | 2 +- .../services/ejb/timer/EjbSchedulerService.java | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-timer/src/main/java/org/jbpm/services/ejb/timer/EJBTimerScheduler.java b/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-timer/src/main/java/org/jbpm/services/ejb/timer/EJBTimerScheduler.java index 4d8092dd81..88ad489d4b 100644 --- a/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-timer/src/main/java/org/jbpm/services/ejb/timer/EJBTimerScheduler.java +++ b/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-timer/src/main/java/org/jbpm/services/ejb/timer/EJBTimerScheduler.java @@ -113,7 +113,7 @@ public void executeTimerJob(Timer timer) { Thread.currentThread().interrupt(); } try { - invokeTransaction(this::executeTimerJobInstance, timerJobInstance); + executeTimerJobInstance(timerJobInstance); } catch (Exception e) { recoverTimerJobInstance(timerJob, timer, e); } diff --git a/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-timer/src/main/java/org/jbpm/services/ejb/timer/EjbSchedulerService.java b/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-timer/src/main/java/org/jbpm/services/ejb/timer/EjbSchedulerService.java index 8643da3057..881d6e4305 100644 --- a/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-timer/src/main/java/org/jbpm/services/ejb/timer/EjbSchedulerService.java +++ b/jbpm-services/jbpm-services-ejb/jbpm-services-ejb-timer/src/main/java/org/jbpm/services/ejb/timer/EjbSchedulerService.java @@ -59,15 +59,12 @@ public class EjbSchedulerService implements GlobalSchedulerService { private static final Logger logger = LoggerFactory.getLogger(EjbSchedulerService.class); - private static final Boolean TRANSACTIONAL = Boolean.parseBoolean(System.getProperty("org.jbpm.ejb.timer.tx", "true")); - private AtomicLong idCounter = new AtomicLong(); private TimerService globalTimerService; private EJBTimerScheduler scheduler; private SchedulerServiceInterceptor interceptor = new DelegateSchedulerServiceInterceptor(this); - @Override public JobHandle scheduleJob(Job job, JobContext ctx, Trigger trigger) { long id = idCounter.getAndIncrement(); @@ -111,7 +108,6 @@ private TimerJobInstance getTimerJobInstance (String uuid) { return unwrapTimerJobInstance(getEjbTimer(getTimerMappinInfo(uuid))); } - @Override public TimerJobInstance getTimerJobInstance(long processInstanceId, long timerId) { return unwrapTimerJobInstance(getEjbTimer(getTimerMappinInfo(processInstanceId, timerId))); @@ -122,8 +118,7 @@ private Timer getEjbTimer(TimerMappingInfo timerMappingInfo) { if(timerMappingInfo == null || timerMappingInfo.getInfo() == null) { return null; } - byte[] data = timerMappingInfo.getInfo(); - return ((TimerHandle) new ObjectInputStream(new ByteArrayInputStream(data)).readObject()).getTimer(); + return ((TimerHandle) new ObjectInputStream(new ByteArrayInputStream(timerMappingInfo.getInfo())).readObject()).getTimer(); } catch (Exception e) { logger.warn("Problem retrieving timer for uuid {}", timerMappingInfo.getUuid(), e); return null; @@ -196,7 +191,6 @@ public void initScheduler(TimerService timerService) { @Override public void shutdown() { // managed by container - no op - } @Override @@ -207,7 +201,7 @@ public JobHandle buildJobHandleForContext(NamedJobContext ctx) { @Override public boolean isTransactional() { - return TRANSACTIONAL; + return true; } @Override @@ -222,8 +216,7 @@ public void setInterceptor(SchedulerServiceInterceptor interceptor) { @Override public boolean isValid(GlobalJobHandle jobHandle) { - - return true; + return true; } protected String getJobName(JobContext ctx, long id) {