cancel
Showing results for 
Search instead for 
Did you mean: 

ActivitiException: this activity doesn't accept signals

derkoe
Champ in-the-making
Champ in-the-making
When I signal a receive task after a parallel gateway, I get "ActivitiException: this activity doesn't accept signals".

Am I doing something wrong?

Here's the Code:

      final String deploymentId = repositoryService.createDeployment()
         .addClasspathResource("diagrams/test.activiti.bpmn20.xml").deploy().getId();

      final HashMap<String, Object> variables = new HashMap<String, Object>();
      variables.put("vehicleId", 42L);
      final ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("helloworld", variables);

      Execution execution = runtimeService.createExecutionQuery().processDefinitionKey("helloworld")
         .variableValueEquals("vehicleId", 42L).singleResult();

      System.out.println(runtimeService.getActiveActivityIds(execution.getId()));

      runtimeService.signal(execution.getId());

The sysout print "[receivetask1]"
7 REPLIES 7

mproch
Champ in-the-making
Champ in-the-making
Hi,
I think that probably your executionQuery does not return correct execution. When you execute it, there are in fact 3 executions for this process:
- global process execution
- 2 executions for both concurrent flows
Your query returns more or less random one I think - and only one of them (the one representing execution waiting in receive node) can be signalled.
You can either:
- get all executions using .list() instead of .singleResult() and manually find the one you want to signal
- or (much better solution IMHO) restrict returned activities by adding .activityId("ID_OF_RECEIVE_TASK") to the query fluent builder.

Hope this helps

derkoe
Champ in-the-making
Champ in-the-making
I thought about it … but this query returns null:
runtimeService.createExecutionQuery()
   .processDefinitionKey("helloworld")
   .variableValueEquals("vehicleId", 42L)
   .list();
And this one the list with only the process instance ([ProcessInstance[5]])
Execution execution = runtimeService.createExecutionQuery()
    .processDefinitionKey("helloworld")
    .variableValueEquals("vehicleId", 42L)
    .activityId("receiveTask")
    .singleResult();

mproch
Champ in-the-making
Champ in-the-making
You're right, there is some problem here - seems like variableValue parameter finds only executions where variable was declared, and not child executions (at least it seems like that…) - don't know if it's intended - maybe it's a bug?

I think the workaround is to find process instance first:
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("helloworld").variableValueEquals("vehicleId", 42L).singleResult();
List<Execution> execution = runtimeService.createExecutionQuery().processInstanceId(pi.getProcessInstanceId()).activityId("receiveTask").list();
-it's somewhat less efficient but should work I think.

derkoe
Champ in-the-making
Champ in-the-making
No, that's also not it. ProcessInstance pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("helloworld").variableValueEquals("vehicleId", 42L).singleResult();
List<Execution> execution = runtimeService.createExecutionQuery().processInstanceId(pi.getProcessInstanceId()).activityId("receiveTask").list();
Your code results in an empty list execution.

Receive tasks only seem to work in a single execution path - if I have Start - receiveTask - End the code works.

Should I file a bug?

mproch
Champ in-the-making
Champ in-the-making
Could you ost also the process definition (xml)? I made small test case (with paralell gateway) and the code I pasted seems to be working… and btw. - which activiti version are you using?

derkoe
Champ in-the-making
Champ in-the-making
Ok, now I have it. This works:
Execution execution = runtimeService.createExecutionQuery()
.processInstanceId(processInstance.getId())
.activityId("receivetask1")
.singleResult();
This doesn't:execution = runtimeService.createExecutionQuery()
.variableValueEquals("vehicleId", 42L)
.activityId("receivetask1")
.singleResult();

There's a test case added, that shows this. Is this a bug? If not this should be defined in the docs.

@mproch: thx for helping,
Chris

frederikherema1
Star Contributor
Star Contributor
Hi,

When a variable value is set on an execution using DelegateExecution.setVariable(s) or runtimeService.setVariable(s) the folowing happens:
  • Execution checks if a variable with the given name is present in collection of variables stored on that execution.

  • If the variable is present, the value is set.

  • If not present, the parent execution's setVariable(s) is called and this will do the same as the steps above.

  • When non of the child-executions in the hierarchy has the var defined locally, the top-execution parent (processInstance, with parent-execution = null) will set the variable locally.
Because of this process, all variables set on executions will be set on the underlying process-instance, which will be queryable using processInstanceQuery.variableValueEquals(…), the execution where the variable was set on (and didn't have the var declared localy) won't return in query results of an executionQuery.

You can explicitally set a execution variable on the execution (and not have it bubble up to a parent which has it defined or root execution) by using setVariableLocal() on the execution.

Hope my explaination is clear for you, still early morning Smiley Wink