cancel
Showing results for 
Search instead for 
Did you mean: 

How do I determine if parallel executions are completed (serviceTask/receiveTask partners)

smith9
Champ in-the-making
Champ in-the-making
I am evaluating Activiti and have a process that is like
Start -> Render Documents (Parallel ServiceTask) -> Render Documents Completed (Parallel ReceiveTask) -> Do Rest of tasks -> End

The process is passed a variable containing the list of documents to be rendered and the rendering process is asynchronous so need to call back when it is completed.

How do I mark off each document as being completed.

My first thought was just to use cardinality and send N signals to the Render Documents Completed (Parallel ReceiveTask)
This has the drawback that if a document happened to be rendered twice for what ever reason, the completion may miss the last documents callback.

Is there an easyway that I can achive something like: signal "document name"

Hope the above is clear enough.
1 REPLY 1

smith9
Champ in-the-making
Champ in-the-making
What I came up with in the end was to use a TaskActivityBehaviour class which combines both service and receive tasks in to one step. Then as each document finishes rendering (receiving a JMS message), I can then signal from the JMS on message to the waiting activiti step.

<code>public class SnsStep extends TaskActivityBehavior {
    private final Logger log = LoggerFactory.getLogger(getClass());

    @Override
    public void execute(ActivityExecution execution) throws Exception {
        log.info("Running Step " + execution.getCurrentActivityName());
    }

    @Override
    public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
        leave(execution);
    }
}
<code>

Is using the TaskActivityBehavior the ideal way to do this?