use of org.jbpm.process.core.timer.impl.GlobalTimerService.DisposableCommandService in project jbpm by kiegroup.
the class GlobalJpaTimerJobInstance method call.
@Override
public Void call() throws Exception {
AsyncExecutionMarker.markAsync();
ExecutableRunner runner = null;
TransactionManager jtaTm = null;
boolean success = false;
try {
JDKCallableJobCommand command = new JDKCallableJobCommand(this);
if (scheduler == null) {
scheduler = (InternalSchedulerService) TimerServiceRegistry.getInstance().get(timerServiceId);
}
if (scheduler == null) {
throw new RuntimeException("No scheduler found for " + timerServiceId);
}
jtaTm = startTxIfNeeded(((GlobalTimerService) scheduler).getRuntimeManager().getEnvironment().getEnvironment());
runner = ((GlobalTimerService) scheduler).getRunner(getJobContext());
runner.execute(command);
GlobalJPATimerJobFactoryManager timerService = ((GlobalJPATimerJobFactoryManager) ((GlobalTimerService) scheduler).getTimerJobFactoryManager());
timerService.removeTimerJobInstance(((DefaultJobHandle) getJobHandle()).getTimerJobInstance());
success = true;
return null;
} catch (Exception e) {
e.printStackTrace();
success = false;
throw e;
} finally {
AsyncExecutionMarker.reset();
if (runner != null && runner instanceof DisposableCommandService) {
if (allowedToDispose(((DisposableCommandService) runner).getEnvironment())) {
logger.debug("Allowed to dispose command service from global timer job instance");
((DisposableCommandService) runner).dispose();
}
}
closeTansactionIfNeeded(jtaTm, success);
}
}
Aggregations