AnsweredAssumed Answered

Trigger Activiti workflow for task sitting in ReceiveTask causes a loop

Question asked by ungawunga on Apr 2, 2013
Latest reply on Apr 4, 2013 by ungawunga
I have an Activiti workflow that contains a ReceiveTask where I'm grouping tasks. I have a Listener that triggers on the event start of the ReceiveTask where I check the property of the newly added task to see if others with the same properties are in the same state. If yes, then I want to trigger them all to move to the next step in the workflow


    <receiveTask id="IssuePost" name="Issue Post">
      <extensionElements>
        <activiti:executionListener event="start" delegateExpression="${IssuePost}"></activiti:executionListener>
      </extensionElements>
    </receiveTask>


My Java Listener class IssuePost gets called when the task moves to the ReceiveTask just fine. I can get the list of other tasks sitting in that ReceiveTask. I'm having a problem triggering the tasks to move to the next step in the workflow. I get caught in a loop when calling "signal" on the tasks. The IssuePost listener keeps on getting triggered in an infinite loop until Alfresco/Activiti gives up and throws an exception.


    List<NodeRef> siblingNodes = searchService.selectNodes( parent, xpath, null, namespacePrefixResolver, false );
    if( siblingNodes.size() == batchCount )
    {
        for( int i=0; i < siblingNodes.size(); i++ )
        {
            List<WorkflowInstance> workflows = workflowService.getWorkflowsForContent( siblingNodes.get( i ), true );
            // this line causes the loop.
            workflowService.signal( workflows.get(0).getId(), null );


How can I signal the tasks in the ReceiveTask to move to the next step in the workflow without triggering the same listener in an infinite loop? There's only one flow out of the ReceiveTask to the next step in the workflow.

Should I signal the workflow in a different way?

I want to use a ReceiveTask since it holds the workflow tasks until I signal them to move on. Other tasks won't do that.

Outcomes