Search in sources :

Example 1 with FailedJobRetryConfiguration

use of org.camunda.bpm.engine.impl.bpmn.parser.FailedJobRetryConfiguration in project camunda-bpm-platform by camunda.

the class ParseUtil method parseRetryIntervals.

public static FailedJobRetryConfiguration parseRetryIntervals(String retryIntervals) {
    if (retryIntervals != null && !retryIntervals.isEmpty()) {
        if (StringUtil.isExpression(retryIntervals)) {
            ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
            Expression expression = expressionManager.createExpression(retryIntervals);
            return new FailedJobRetryConfiguration(expression);
        }
        String[] intervals = StringUtil.split(retryIntervals, ",");
        int retries = intervals.length + 1;
        if (intervals.length == 1) {
            try {
                DurationHelper durationHelper = new DurationHelper(intervals[0]);
                if (durationHelper.isRepeat()) {
                    retries = durationHelper.getTimes();
                }
            } catch (Exception e) {
                LOG.logParsingRetryIntervals(intervals[0], e);
                return null;
            }
        }
        return new FailedJobRetryConfiguration(retries, Arrays.asList(intervals));
    } else {
        return null;
    }
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) DurationHelper(org.camunda.bpm.engine.impl.calendar.DurationHelper) Expression(org.camunda.bpm.engine.impl.el.Expression) FailedJobRetryConfiguration(org.camunda.bpm.engine.impl.bpmn.parser.FailedJobRetryConfiguration) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) NotValidException(org.camunda.bpm.engine.exception.NotValidException)

Example 2 with FailedJobRetryConfiguration

use of org.camunda.bpm.engine.impl.bpmn.parser.FailedJobRetryConfiguration in project camunda-bpm-platform by camunda.

the class DefaultJobRetryCmd method executeCustomStrategy.

protected void executeCustomStrategy(CommandContext commandContext, JobEntity job, ActivityImpl activity) throws Exception {
    FailedJobRetryConfiguration retryConfiguration = getFailedJobRetryConfiguration(job, activity);
    if (retryConfiguration == null) {
        executeStandardStrategy(commandContext);
    } else {
        if (isFirstJobExecution(job)) {
            // then change default retries to the ones configured
            initializeRetries(job, retryConfiguration.getRetries());
        } else {
            LOG.debugDecrementingRetriesForJob(job.getId());
        }
        List<String> intervals = retryConfiguration.getRetryIntervals();
        int intervalsCount = intervals.size();
        int indexOfInterval = Math.max(0, Math.min(intervalsCount - 1, intervalsCount - (job.getRetries() - 1)));
        DurationHelper durationHelper = getDurationHelper(intervals.get(indexOfInterval));
        job.setLockExpirationTime(durationHelper.getDateAfter());
        logException(job);
        decrementRetries(job);
        notifyAcquisition(commandContext);
    }
}
Also used : DurationHelper(org.camunda.bpm.engine.impl.calendar.DurationHelper) FailedJobRetryConfiguration(org.camunda.bpm.engine.impl.bpmn.parser.FailedJobRetryConfiguration)

Example 3 with FailedJobRetryConfiguration

use of org.camunda.bpm.engine.impl.bpmn.parser.FailedJobRetryConfiguration in project camunda-bpm-platform by camunda.

the class DefaultJobRetryCmd method getFailedJobRetryConfiguration.

protected FailedJobRetryConfiguration getFailedJobRetryConfiguration(JobEntity job, ActivityImpl activity) {
    FailedJobRetryConfiguration retryConfiguration = activity.getProperties().get(DefaultFailedJobParseListener.FAILED_JOB_CONFIGURATION);
    while (retryConfiguration != null && retryConfiguration.getExpression() != null) {
        String retryIntervals = getFailedJobRetryTimeCycle(job, retryConfiguration.getExpression());
        retryConfiguration = ParseUtil.parseRetryIntervals(retryIntervals);
    }
    return retryConfiguration;
}
Also used : FailedJobRetryConfiguration(org.camunda.bpm.engine.impl.bpmn.parser.FailedJobRetryConfiguration)

Aggregations

FailedJobRetryConfiguration (org.camunda.bpm.engine.impl.bpmn.parser.FailedJobRetryConfiguration)3 DurationHelper (org.camunda.bpm.engine.impl.calendar.DurationHelper)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 NotValidException (org.camunda.bpm.engine.exception.NotValidException)1 Expression (org.camunda.bpm.engine.impl.el.Expression)1 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)1