Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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 @@ -24,13 +24,17 @@
import org.flowable.engine.impl.util.ProcessInstanceHelper;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.eventsubscription.service.impl.persistence.entity.EventSubscriptionEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Daniel Meyer
* @author Joram Barrez
*/
public class SignalEventHandler extends AbstractEventHandler {

private static final Logger LOG = LoggerFactory.getLogger(SignalEventHandler.class);

public static final String EVENT_HANDLER_TYPE = "signal";

@Override
Expand All @@ -52,7 +56,8 @@ public void handleEvent(EventSubscriptionEntity eventSubscription, Object payloa
ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId);

if (processDefinition.isSuspended()) {
throw new FlowableException("Could not handle signal: process definition with id: " + processDefinitionId + " is suspended for " + eventSubscription);
LOG.info("Could not handle signal: process definition with id: {} is suspended for {}", processDefinitionId, eventSubscription);
return;
}

// Start process instance via the flow element linked to the event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,30 @@ public void testSignalUserTask() {
.isExactlyInstanceOf(FlowableException.class);
}

@Test
public void testDuplicatedSuspendedSignalStartEventFromProcess() {
// Deploy test processes
repositoryService.createDeployment()
.addClasspathResource("org/flowable/engine/test/bpmn/event/signal/SignalEventTest.testSignalStartEvent.bpmn20.xml")
.deploy();
Comment thread
martin-grofcik marked this conversation as resolved.
Outdated
repositoryService.suspendProcessDefinitionByKey("processWithSignalStart1");

// An example of behavior when there is no subscription to the signal.
runtimeService.signalEventReceived("nonExisting");

// Starting the process that fires the signal should start 2 process
// instances that are listening on that signal. The suspended one is not included.
runtimeService.startProcessInstanceByKey("processWithSignalThrow");

// Verify
assertThat(runtimeService.createProcessInstanceQuery().count()).isEqualTo(2);
assertThat(taskService.createTaskQuery().list()).extracting(Task::getName)
.containsExactlyInAnyOrder("Task in process B", "Task in process C");

// Cleanup
cleanup();
Comment thread
martin-grofcik marked this conversation as resolved.
Outdated
}

@Test
public void testSignalStartEventFromProcess() {

Expand Down Expand Up @@ -805,12 +829,13 @@ public void testSignalStartEventWithSuspendedDefinition() {

repositoryService.suspendProcessDefinitionByKey("processWithSignalStart1");

assertThatThrownBy(() -> runtimeService.startProcessInstanceByKey("processWithSignalThrow"))
.as("Suspended process definition should fail")
.isExactlyInstanceOf(FlowableException.class);
runtimeService.startProcessInstanceByKey("processWithSignalThrow");

// Verify
assertThat(runtimeService.createProcessInstanceQuery().count()).isZero();
assertThat(runtimeService.createProcessInstanceQuery().list())
.as("Signal throw event is swallowed for suspended process")
.extracting(ProcessInstance::getProcessDefinitionKey)
.containsExactlyInAnyOrder("processWithSignalStart2","processWithSignalStart3");

repositoryService.activateProcessDefinitionByKey("processWithSignalStart1");

Expand All @@ -819,8 +844,8 @@ public void testSignalStartEventWithSuspendedDefinition() {
runtimeService.startProcessInstanceByKey("processWithSignalThrow");

// Verify
assertThat(runtimeService.createProcessInstanceQuery().count()).isEqualTo(3);
assertThat(taskService.createTaskQuery().count()).isEqualTo(3);
assertThat(runtimeService.createProcessInstanceQuery().count()).isEqualTo(5);
assertThat(taskService.createTaskQuery().count()).isEqualTo(5);

// Cleanup
cleanup();
Expand Down