Search in sources :

Example 1 with TimerJobConfiguration

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

the class TimerEventJobHandler method newConfiguration.

@Override
public TimerJobConfiguration newConfiguration(String canonicalString) {
    String[] configParts = canonicalString.split("\\" + JOB_HANDLER_CONFIG_PROPERTY_DELIMITER);
    if (configParts.length > 2) {
        throw new ProcessEngineException("Illegal timer job handler configuration: '" + canonicalString + "': exprecting a one or two part configuration seperated by '" + JOB_HANDLER_CONFIG_PROPERTY_DELIMITER + "'.");
    }
    TimerJobConfiguration configuration = new TimerJobConfiguration();
    configuration.timerElementKey = configParts[0];
    if (configParts.length == 2) {
        configuration.followUpJobCreated = JOB_HANDLER_CONFIG_PROPERTY_FOLLOW_UP_JOB_CREATED.equals(configParts[1]);
    }
    return configuration;
}
Also used : TimerJobConfiguration(org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler.TimerJobConfiguration) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 2 with TimerJobConfiguration

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

the class MigratingTimerJobInstance method migrateJobHandlerConfiguration.

@Override
protected void migrateJobHandlerConfiguration() {
    TimerJobConfiguration configuration = (TimerJobConfiguration) jobEntity.getJobHandlerConfiguration();
    configuration.setTimerElementKey(timerTriggerTargetScope.getId());
    jobEntity.setJobHandlerConfiguration(configuration);
    if (updateEvent) {
        targetJobDeclaration.updateJob((TimerEntity) jobEntity);
    }
}
Also used : TimerJobConfiguration(org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler.TimerJobConfiguration)

Example 3 with TimerJobConfiguration

use of org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler.TimerJobConfiguration 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

TimerJobConfiguration (org.camunda.bpm.engine.impl.jobexecutor.TimerEventJobHandler.TimerJobConfiguration)3 Date (java.util.Date)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)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