Skip to content

Commit

Permalink
feat(engine): introduce global retry configuration
Browse files Browse the repository at this point in the history
-provide default global retry conf.
-no need for enabling the retry configuration anymore
-rename Fox* related classes to Default*
-add new test
-refactor the existing engine configurations

Related to CAM-8087
yanavasileva committed Aug 17, 2017
1 parent 5e412b2 commit 7e9dd9d
Showing 26 changed files with 349 additions and 199 deletions.
Original file line number Diff line number Diff line change
@@ -16,9 +16,9 @@
import java.util.List;

import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
import org.camunda.bpm.engine.impl.bpmn.parser.FoxFailedJobParseListener;
import org.camunda.bpm.engine.impl.bpmn.parser.DefaultFailedJobParseListener;
import org.camunda.bpm.engine.impl.cfg.JtaProcessEngineConfiguration;
import org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory;
import org.camunda.bpm.engine.impl.jobexecutor.DefaultFailedJobCommandFactory;
import org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator;

/**
@@ -47,9 +47,9 @@ protected void initCustomJobRetryStrategy() {
customPostBPMNParseListeners = new ArrayList<BpmnParseListener>();
setCustomPostBPMNParseListeners(customPostBPMNParseListeners);
}
customPostBPMNParseListeners.add(new FoxFailedJobParseListener());
customPostBPMNParseListeners.add(new DefaultFailedJobParseListener());

setFailedJobCommandFactory(new FoxFailedJobCommandFactory());
setFailedJobCommandFactory(new DefaultFailedJobCommandFactory());
}

protected void initIdGenerator() {
Original file line number Diff line number Diff line change
@@ -29,9 +29,6 @@
<property name="jobExecutorActivate" value="false" />
<property name="deploymentResources" value="classpath*:bpmn/*.bpmn" />
<property name="authorizationEnabled" value="true" />
<property name="failedJobCommandFactory">
<bean class="org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory" />
</property>
<property name="idGenerator">
<bean class="org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator" />
</property>
Original file line number Diff line number Diff line change
@@ -29,9 +29,6 @@
<property name="jobExecutorActivate" value="false" />
<property name="deploymentResources" value="classpath*:bpmn/*.bpmn" />
<property name="authorizationEnabled" value="true" />
<property name="failedJobCommandFactory">
<bean class="org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory" />
</property>
<property name="idGenerator">
<bean class="org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator" />
</property>
Original file line number Diff line number Diff line change
@@ -16,9 +16,9 @@
import java.util.List;

import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
import org.camunda.bpm.engine.impl.bpmn.parser.FoxFailedJobParseListener;
import org.camunda.bpm.engine.impl.bpmn.parser.DefaultFailedJobParseListener;
import org.camunda.bpm.engine.impl.cfg.JtaProcessEngineConfiguration;
import org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory;
import org.camunda.bpm.engine.impl.jobexecutor.DefaultFailedJobCommandFactory;
import org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator;

/**
@@ -47,9 +47,9 @@ protected void initCustomJobRetryStrategy() {
customPostBPMNParseListeners = new ArrayList<BpmnParseListener>();
setCustomPostBPMNParseListeners(customPostBPMNParseListeners);
}
customPostBPMNParseListeners.add(new FoxFailedJobParseListener());
customPostBPMNParseListeners.add(new DefaultFailedJobParseListener());

setFailedJobCommandFactory(new FoxFailedJobCommandFactory());
setFailedJobCommandFactory(new DefaultFailedJobCommandFactory());
}

protected void initIdGenerator() {
10 changes: 0 additions & 10 deletions engine-plugins/spin-plugin/src/test/resources/camunda.cfg.xml
Original file line number Diff line number Diff line change
@@ -19,24 +19,14 @@

<!-- mail server configurations -->
<property name="history" value="full" />

<property name="customPostBPMNParseListeners">
<list>
<bean class="org.camunda.bpm.engine.impl.bpmn.parser.FoxFailedJobParseListener" />
</list>
</property>

<property name="failedJobCommandFactory" ref="foxFailedJobCommandFactory" />

<property name="processEnginePlugins">
<list>
<bean class="org.camunda.spin.plugin.impl.SpinProcessEnginePlugin" />
</list>
</property>
</bean>

<bean id="foxFailedJobCommandFactory" class="org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory" />

<!--<bean id="uuidGenerator" class="org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator" />-->

</beans>
Original file line number Diff line number Diff line change
@@ -28,14 +28,6 @@

<property name="history" value="full"/>

<property name="customPostBPMNParseListeners">
<list>
<bean class="org.camunda.bpm.engine.impl.bpmn.parser.FoxFailedJobParseListener"/>
</list>
</property>

<property name="failedJobCommandFactory" ref="foxFailedJobCommandFactory"/>

</bean>

<bean id="processEngineRule" class="org.camunda.bpm.engine.test.ProcessEngineRule">
@@ -58,8 +50,6 @@
<context:annotation-config/>


<bean id="foxFailedJobCommandFactory" class="org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory"/>

<bean id="userBean" class="org.camunda.bpm.engine.spring.test.transaction.modification.UserBean"></bean>
<bean id="deleteVariableListener" class="org.camunda.bpm.engine.spring.test.transaction.modification.DeleteVariableListener"></bean>
<bean id="calculateTimerDate" class="org.camunda.bpm.engine.spring.test.transaction.modification.CalculateTimerDate"></bean>
Original file line number Diff line number Diff line change
@@ -27,17 +27,8 @@
<!-- turn off metrics reporter -->
<property name="dbMetricsReporterActivate" value="false" />

<property name="customPostBPMNParseListeners">
<list>
<bean class="org.camunda.bpm.engine.impl.bpmn.parser.FoxFailedJobParseListener" />
</list>
</property>

<property name="failedJobCommandFactory" ref="foxFailedJobCommandFactory" />
</bean>

<bean id="foxFailedJobCommandFactory" class="org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory" />

<bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
Original file line number Diff line number Diff line change
@@ -12,8 +12,6 @@
*/
package org.camunda.bpm.container.impl.deployment;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.camunda.bpm.application.AbstractProcessApplication;
@@ -28,12 +26,9 @@
import org.camunda.bpm.container.impl.spi.PlatformServiceContainer;
import org.camunda.bpm.container.impl.spi.ServiceTypes;
import org.camunda.bpm.engine.impl.ProcessEngineLogger;
import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
import org.camunda.bpm.engine.impl.bpmn.parser.FoxFailedJobParseListener;
import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.camunda.bpm.engine.impl.cfg.ProcessEnginePlugin;
import org.camunda.bpm.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.camunda.bpm.engine.impl.jobexecutor.FoxFailedJobCommandFactory;
import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor;
import org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator;
import org.camunda.bpm.engine.impl.util.ReflectUtil;
@@ -89,8 +84,6 @@ public void performOperationStep(DeploymentOperation operationContext) {
ProcessEngineConfigurationImpl configurationImpl = configuration;
configurationImpl.setIdGenerator(new StrongUuidGenerator());

configureCustomRetryStrategy(configurationImpl);

// set configuration values
String name = processEngineXml.getName();
configuration.setProcessEngineName(name);
@@ -130,18 +123,6 @@ protected JmxManagedProcessEngineController createProcessEngineControllerInstanc
return new JmxManagedProcessEngineController(configuration);
}

protected void configureCustomRetryStrategy(ProcessEngineConfigurationImpl configurationImpl) {
// add support for custom Retry strategy
// TODO: decide whether this should be moved to configuration or to plugin
List<BpmnParseListener> customPostBPMNParseListeners = configurationImpl.getCustomPostBPMNParseListeners();
if(customPostBPMNParseListeners==null) {
customPostBPMNParseListeners = new ArrayList<BpmnParseListener>();
configurationImpl.setCustomPostBPMNParseListeners(customPostBPMNParseListeners);
}
customPostBPMNParseListeners.add(new FoxFailedJobParseListener());
configurationImpl.setFailedJobCommandFactory(new FoxFailedJobCommandFactory());
}

/**
* <p>Instantiates and applies all {@link ProcessEnginePlugin}s defined in the processEngineXml
*/
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
import org.camunda.bpm.engine.impl.util.xml.Element;
import org.camunda.bpm.engine.impl.util.xml.Namespace;

public class FoxFailedJobParseListener extends AbstractBpmnParseListener {
public class DefaultFailedJobParseListener extends AbstractBpmnParseListener {

protected static final String TYPE = "type";
protected static final String START_TIMER_EVENT = "startTimerEvent";
Original file line number Diff line number Diff line change
@@ -99,6 +99,7 @@
import org.camunda.bpm.engine.impl.bpmn.deployer.BpmnDeployer;
import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseListener;
import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParser;
import org.camunda.bpm.engine.impl.bpmn.parser.DefaultFailedJobParseListener;
import org.camunda.bpm.engine.impl.calendar.BusinessCalendarManager;
import org.camunda.bpm.engine.impl.calendar.CycleBusinessCalendar;
import org.camunda.bpm.engine.impl.calendar.DueDateBusinessCalendar;
@@ -187,10 +188,10 @@
import org.camunda.bpm.engine.impl.interceptor.DelegateInterceptor;
import org.camunda.bpm.engine.impl.interceptor.SessionFactory;
import org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler;
import org.camunda.bpm.engine.impl.jobexecutor.DefaultFailedJobCommandFactory;
import org.camunda.bpm.engine.impl.jobexecutor.DefaultJobExecutor;
import org.camunda.bpm.engine.impl.jobexecutor.DefaultJobPriorityProvider;
import org.camunda.bpm.engine.impl.jobexecutor.FailedJobCommandFactory;
import org.camunda.bpm.engine.impl.jobexecutor.DefaultFailedJobCommandFactory;
import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration;
import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor;
import org.camunda.bpm.engine.impl.jobexecutor.JobHandler;
@@ -709,6 +710,8 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig

private int failedJobListenerMaxRetries = DEFAULT_FAILED_JOB_LISTENER_MAX_RETRIES;

private String failedJobRetryTimeCycle;

// buildProcessEngine ///////////////////////////////////////////////////////

@Override
@@ -743,6 +746,7 @@ protected void init() {
initCommandExecutors();
initServices();
initIdGenerator();
initFailedJobCommandFactory();
initDeployers();
initJobProvider();
initExternalTaskPriorityProvider();
@@ -758,7 +762,6 @@ protected void init() {
initJpa();
initDelegateInterceptor();
initEventHandlers();
initFailedJobCommandFactory();
initProcessApplicationManager();
initCorrelationHandler();
initIncidentHandlers();
@@ -872,6 +875,10 @@ protected void initFailedJobCommandFactory() {
if (failedJobCommandFactory == null) {
failedJobCommandFactory = new DefaultFailedJobCommandFactory();
}
if (postParseListeners == null) {
postParseListeners = new ArrayList<BpmnParseListener>();
}
postParseListeners.add(new DefaultFailedJobParseListener());
}

// incident handlers /////////////////////////////////////////////////////////////
@@ -3797,4 +3804,12 @@ public int getFailedJobListenerMaxRetries() {
public void setFailedJobListenerMaxRetries(int failedJobListenerMaxRetries) {
this.failedJobListenerMaxRetries = failedJobListenerMaxRetries;
}

public String getFailedJobRetryTimeCycle() {
return failedJobRetryTimeCycle;
}

public void setFailedJobRetryTimeCycle(String failedJobRetryTimeCycle) {
this.failedJobRetryTimeCycle = failedJobRetryTimeCycle;
}
}
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
package org.camunda.bpm.engine.impl.cmd;

import org.camunda.bpm.engine.impl.ProcessEngineLogger;
import org.camunda.bpm.engine.impl.bpmn.parser.FoxFailedJobParseListener;
import org.camunda.bpm.engine.impl.bpmn.parser.DefaultFailedJobParseListener;
import org.camunda.bpm.engine.impl.calendar.DurationHelper;
import org.camunda.bpm.engine.impl.context.Context;
import org.camunda.bpm.engine.impl.el.Expression;
@@ -31,7 +31,7 @@
/**
* @author Roman Smirnov
*/
public class FoxJobRetryCmd extends JobRetryCmd {
public class DefaultJobRetryCmd extends JobRetryCmd {

public static final List<String> SUPPORTED_TYPES = Arrays.asList(
TimerExecuteNestedActivityJobHandler.TYPE,
@@ -42,22 +42,23 @@ public class FoxJobRetryCmd extends JobRetryCmd {
);
private final static JobExecutorLogger LOG = ProcessEngineLogger.JOB_EXECUTOR_LOGGER;

public FoxJobRetryCmd(String jobId, Throwable exception) {
public DefaultJobRetryCmd(String jobId, Throwable exception) {
super(jobId, exception);
}

public Object execute(CommandContext commandContext) {
JobEntity job = getJob();

ActivityImpl activity = getCurrentActivity(commandContext, job);
String globalFailedJobRetryTimeCycle = commandContext.getProcessEngineConfiguration().getFailedJobRetryTimeCycle();

if (activity == null) {
if (activity == null && globalFailedJobRetryTimeCycle == null) {
LOG.debugFallbackToDefaultRetryStrategy();
executeStandardStrategy(commandContext);

} else {
try {
executeCustomStrategy(commandContext, job, activity);
executeCustomStrategy(commandContext, job, activity, globalFailedJobRetryTimeCycle);

} catch (Exception e) {
LOG.debugFallbackToDefaultRetryStrategy();
@@ -73,10 +74,17 @@ protected void executeStandardStrategy(CommandContext commandContext) {
decrementCmd.execute(commandContext);
}

protected void executeCustomStrategy(CommandContext commandContext, JobEntity job, ActivityImpl activity) throws Exception {
String failedJobRetryTimeCycle = getFailedJobRetryTimeCycle(job, activity);
protected void executeCustomStrategy(CommandContext commandContext, JobEntity job, ActivityImpl activity, String globalFailedJobRetryTimeCycle) throws Exception {
String failedJobRetryTimeCycle = null;
if (activity != null) {
failedJobRetryTimeCycle = getFailedJobRetryTimeCycle(job, activity);
}

if (failedJobRetryTimeCycle == null && globalFailedJobRetryTimeCycle != null) {
failedJobRetryTimeCycle = globalFailedJobRetryTimeCycle;
}

if(failedJobRetryTimeCycle == null) {
if (failedJobRetryTimeCycle == null) {
executeStandardStrategy(commandContext);

} else {
@@ -123,7 +131,7 @@ protected ExecutionEntity fetchExecutionEntity(String executionId) {

protected String getFailedJobRetryTimeCycle(JobEntity job, ActivityImpl activity) {

Expression expression = activity.getProperties().get(FoxFailedJobParseListener.FOX_FAILED_JOB_CONFIGURATION);
Expression expression = activity.getProperties().get(DefaultFailedJobParseListener.FOX_FAILED_JOB_CONFIGURATION);

String executionId = job.getExecutionId();
ExecutionEntity execution = null;
@@ -134,6 +142,10 @@ protected String getFailedJobRetryTimeCycle(JobEntity job, ActivityImpl activity

Object value = null;

if (expression == null) {
return null;
}

try {
value = expression.getValue(execution);
}
Original file line number Diff line number Diff line change
@@ -12,14 +12,14 @@
*/
package org.camunda.bpm.engine.impl.jobexecutor;

import org.camunda.bpm.engine.impl.cmd.DecrementJobRetriesCmd;
import org.camunda.bpm.engine.impl.cmd.DefaultJobRetryCmd;
import org.camunda.bpm.engine.impl.interceptor.Command;


public class DefaultFailedJobCommandFactory implements FailedJobCommandFactory {

public Command<Object> getCommand(String jobId, Throwable exception) {
return new DecrementJobRetriesCmd(jobId, exception);
return new DefaultJobRetryCmd(jobId, exception);
}

}

This file was deleted.

Loading

0 comments on commit 7e9dd9d

Please sign in to comment.