cancel
Showing results for 
Search instead for 
Did you mean: 

Signal Event Subscription is in suspended state after resuming process

prachi_mujumdar
Champ in-the-making
Champ in-the-making
Hi,

I have Process A which I am suspending. As per business requirement when a particular condition is met, I need to resume the process and send a signal to it.

This works fine if I have single process instance in suspended state. But if I have multiple process instances of same process in suspended state then I get following error:

org.activiti.engine.ActivitiException: Cannot throw signal event 'SomeSignalName' because execution '2666' is suspended
   at org.activiti.engine.impl.cmd.SignalEventReceivedCmd.execute(SignalEventReceivedCmd.java:61)
   at org.activiti.engine.impl.cmd.SignalEventReceivedCmd.execute(SignalEventReceivedCmd.java:33)
   at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
   at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:61)
   at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
   at org.activiti.engine.impl.RuntimeServiceImpl.signalEventReceived(RuntimeServiceImpl.java:233)

I am using following code :

To suspend the process

runtimeService.suspendProcessInstanceById(processInstanceId);


To resume a process

runtimeService.activateProcessInstanceById(processInstanceId);


And to send event signal

ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstanceId).signalEventSubscriptionName(signalName);
        if (executionQuery != null) {
                   Execution execution = executionQuery.singleResult();
         runtimeService.signalEventReceived(eventSignal, execution.getId());
       }

Can anyone please help me in this?
2 REPLIES 2

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Prachi.

I tried to reproduce your issue with jUnit test. Following test is based on activiti 5.15 sources and jUnit test.


  @Deployment(resources = "org/activiti/engine/test/api/runtime/ProcessInstanceSuspensionTest.testSignalEventReceivedAfterProcessInstanceSuspended.bpmn20.xml")
  public void testSignalEventReceivedAfterMultipleProcessInstancesSuspended() {

    final String signal = "Some Signal";

    // Test if process instance can be completed using the signal
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalSuspendedProcessInstance");
    runtimeService.startProcessInstanceByKey("signalSuspendedProcessInstance");
    runtimeService.signalEventReceived(signal);
    assertEquals(0, runtimeService.createProcessInstanceQuery().count());

    // Now test when suspending the process instance: the process instance shouldn't be continued
    processInstance = runtimeService.startProcessInstanceByKey("signalSuspendedProcessInstance");
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    processInstance = runtimeService.startProcessInstanceByKey("signalSuspendedProcessInstance");
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    runtimeService.signalEventReceived(signal);
    assertEquals(2, runtimeService.createProcessInstanceQuery().count());

    runtimeService.signalEventReceived(signal, new HashMap<String, Object>());
    assertEquals(2, runtimeService.createProcessInstanceQuery().count());

    // Activate and try again
    runtimeService.activateProcessInstanceById(processInstance.getId());
    runtimeService.signalEventReceived(signal);
    assertEquals(1, runtimeService.createProcessInstanceQuery().count());
  }

I started/suspended 2 process instances. They were not activated by signals. After that I activated one of them and sent a signal. Activated process instance was finished. Is seems that it works as you expected.

Regards
Martin

martin_grofcik
Confirmed Champ
Confirmed Champ