0
votes

I'm very new to the world of BPMN 2.0 (Camunda). I need to model a pretty complicated workflow, described below. Any help is highly appreciated!

A single process has an "event loop" that captures task event from an external system, then it submits the task asynchronously for execution to the external system and awaits for its completion status though POST rest callback mechanism. Any number of such tasks events can come in until a specific message is received that marks the end of task list. At this point the main process should check if all asynchronously submitted tasks have completed or wait for still running tasks to complete. If any of tasks failed then the whole process should be marked as failed.

2

2 Answers

0
votes

This scenario very closely resembles one we have implemented at a customer of ours.

However, you will need to think about the problem in a different fashion. Neither Camunda or it's predecessor engine (Activiti) have the ability to handle what I like to term "durable" messages. A "durable" message is one that will persist within the engine until such time as the engine comes and looks for it. Generally, if you are using a pub/sob message platform such as JMS, this isn't a problem. But if you are communicating via http over tcp, then this can be troublesome as MESSAGES can be MISSED/LOST.

So, I am assuming (based on your description) that you are planning n using http over tcp.

So, in order to make sure you don't lose messages, you need to abandon the "loop" paradigm. With a loop, you can't guarantee the process instance will be waiting at a receive task when the message comes in.

So, rather than using a loop, you should consider a single "instance" process that is triggered by a message start event, the message start event will include a business data key that acts as the correlation across related instances.

The basic flow is below:

enter image description here

Notice that the flow is very simple, receive the message, make the async call and wait for a success message, then end.

There is a decision gateway that determines if the incoming message is the end of list task. If this is detected, we branch, query the active instances with the same correlation key and wait for instances ti either fail or complet. If complete,the final task process instance completes and updates appropriate audit trail.

If on completion of the instances ANY fail, then the "final task" instance handles the error condition.

0
votes

You can use receive task of activiti to achieve this.

http://www.activiti.org/userguide/#bpmnReceiveTask

I had similar situation where in my workflow we had to wait for inputs from external application. You can use wait task and then when you receive that data you have to explicitly signal this task so that execution moves to next stage.