Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public Object execute(CommandContext commandContext) {
}

if (executionEntity != null) {
executionEntity.setActive(false);

if (StringUtils.isNotEmpty(failedJobRetryTimeCycleValue)) {
ExpressionManager expressionManager = processEngineConfig.getExpressionManager();
if (expressionManager != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.impl.history.HistoryLevel;
import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.impl.test.HistoryTestHelper;
import org.flowable.engine.impl.test.PluggableFlowableTestCase;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;
Expand Down Expand Up @@ -221,6 +226,44 @@ public void testTimerWithCycle() throws Exception {
.doesNotThrowAnyException();
}

@Test
@Deployment
public void testTimerRetriedAfterFailure() {
ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder()
.processDefinitionKey("nonInterruptingTimerRetry")
.variable("failTimer", true)
.start();

Job timerJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
managementService.moveTimerToExecutableJob(timerJob.getId());
assertThatThrownBy(() -> managementService.executeJob(timerJob.getId()))
.isInstanceOf(FlowableException.class)
.hasStackTraceContaining("Timer failed");

Job retriedTimerJob = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).singleResult();
assertThat(retriedTimerJob.getRetries()).isEqualTo(2);

runtimeService.setVariable(processInstance.getId(), "failTimer", false);
managementService.moveTimerToExecutableJob(retriedTimerJob.getId());
managementService.executeJob(retriedTimerJob.getId());

assertThat(runtimeService.getActiveActivityIds(processInstance.getId())).containsExactlyInAnyOrder("task", "timer");

Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.complete(task.getId());
assertProcessEnded(processInstance.getId());

if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) {
assertThat(historyService.createHistoricActivityInstanceQuery()
.processInstanceId(processInstance.getId())
.activityId("timer")
.list())
.extracting(HistoricActivityInstance::getEndTime)
.hasSize(2)
.doesNotContainNull();
}
}

/*
* see https://activiti.atlassian.net/browse/ACT-1173
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
targetNamespace="Examples">

<process id="nonInterruptingTimerRetry">

<startEvent id="theStart"/>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="task"/>

<userTask id="task"/>
<sequenceFlow id="flow2" sourceRef="task" targetRef="end"/>

<boundaryEvent id="timer" attachedToRef="task" cancelActivity="false">
<timerEventDefinition>
<timeDuration>PT1H</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<sequenceFlow id="flow3" sourceRef="timer" targetRef="timerFiredTask"/>
<scriptTask id="timerFiredTask" scriptFormat="groovy">
<script>
if (failTimer) {
throw new RuntimeException("Timer failed")
}
</script>
</scriptTask>
<sequenceFlow id="flow4" sourceRef="timerFiredTask" targetRef="nonInterruptingEnd"/>
<endEvent id="nonInterruptingEnd"/>

<endEvent id="end"/>

</process>
</definitions>
Loading