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;
}
}
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);
}
}
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;
}
Aggregations