protected void executeJob() { try { commandExecutor.execute(new ExecuteAsyncJobCmd(job)); } catch (final ActivitiOptimisticLockingException e) { handleFailedJob(e); if (log.isDebugEnabled()) { log.debug( "Optimistic locking exception during job execution. If you have multiple async executors running against the same database, " + "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." + "This is expected behavior in a clustered environment. " + "You can ignore this message if you indeed have multiple job executor threads running against the same database. " + "Exception message: {}", e.getMessage()); } } catch (Throwable exception) { handleFailedJob(exception); // Finally, Throw the exception to indicate the ExecuteAsyncJobCmd failed String message = "Job " + job.getId() + " failed"; log.error(message, exception); } }
protected void unlockJobIfNeeded() { try { if (job.isExclusive()) { commandExecutor.execute(new UnlockExclusiveJobCmd(job)); } } catch (ActivitiOptimisticLockingException optimisticLockingException) { if (log.isDebugEnabled()) { log.debug( "Optimistic locking exception while unlocking the job. If you have multiple async executors running against the same database, " + "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." + "This is expected behavior in a clustered environment. " + "You can ignore this message if you indeed have multiple job executor acquisition threads running against the same database. " + "Exception message: {}", optimisticLockingException.getMessage()); } } catch (Throwable t) { log.error("Error while unlocking exclusive job " + job.getId(), t); } }