Search in sources :

Example 1 with RepeatingFailedJobListener

use of org.camunda.bpm.engine.impl.jobexecutor.RepeatingFailedJobListener in project camunda-bpm-platform by camunda.

the class TimerEntity method preExecute.

@Override
protected void preExecute(CommandContext commandContext) {
    if (getJobHandler() instanceof TimerEventJobHandler) {
        TimerJobConfiguration configuration = (TimerJobConfiguration) getJobHandlerConfiguration();
        if (repeat != null && !configuration.isFollowUpJobCreated()) {
            // this timer is a repeating timer and
            // a follow up timer job has not been scheduled yet
            Date newDueDate = calculateRepeat();
            if (newDueDate != null) {
                // the listener is added to the transaction as SYNC on ROLLABCK,
                // when it is necessary to schedule a new timer job invocation.
                // If the transaction does not rollback, it is ignored.
                ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
                CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequiresNew();
                RepeatingFailedJobListener listener = createRepeatingFailedJobListener(commandExecutor);
                commandContext.getTransactionContext().addTransactionListener(TransactionState.ROLLED_BACK, listener);
                // create a new timer job
                createNewTimerJob(newDueDate);
            }
        }
    }
}
Also used : RepeatingFailedJobListener(org.camunda.bpm.engine.impl.jobexecutor.RepeatingFailedJobListener) TimerEventJobHandler(org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler) CommandExecutor(org.camunda.bpm.engine.impl.interceptor.CommandExecutor) TimerJobConfiguration(org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler.TimerJobConfiguration) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)1 RepeatingFailedJobListener (org.camunda.bpm.engine.impl.jobexecutor.RepeatingFailedJobListener)1 TimerEventJobHandler (org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler)1 TimerJobConfiguration (org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler.TimerJobConfiguration)1