use of org.jbpm.process.core.timer.impl.GlobalTimerService 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);
}
}
use of org.jbpm.process.core.timer.impl.GlobalTimerService in project jbpm by kiegroup.
the class AbstractRuntimeManager method close.
public void close(boolean removeJobs) {
cacheManager.dispose();
environment.close();
registry.remove(identifier);
TimerService timerService = TimerServiceRegistry.getInstance().get(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX);
if (timerService != null) {
try {
if (removeJobs && timerService instanceof GlobalTimerService) {
((GlobalTimerService) timerService).destroy();
}
timerService.shutdown();
GlobalSchedulerService schedulerService = ((SchedulerProvider) environment).getSchedulerService();
if (schedulerService != null) {
schedulerService.shutdown();
}
} finally {
TimerServiceRegistry.getInstance().remove(getIdentifier() + TimerServiceRegistry.TIMER_SERVICE_SUFFIX);
}
}
this.closed = true;
}
Aggregations