2
votes

I have 2 separate synchronous "service tasks" in BPMN2.0 diagram - "Action 1" and "Action 2".

After successful executing of "Action 1", an outside event is expected (some action outside the system managed by BPM engine). After the event occurance, "Action 2" should be executed immediately (again, synchronous service task).

The complicated part for me is how to define timeout for the event, meaning event is expected, but only for some time (e.g. 1 minute)... Afterward, some timeout error handling should be executed.

So Action 2 should be executed in range 0 to 60 seconds after Action 1, as soon as possible, or not at all.

Any idea how to achieve this without using asynchronous task (see second picture)?

I have some idea (third picture), but I'm not sure if it would work as expected...

The diagram will be executed in Activiti BPM engine...

Synchronous execution

Synchronous execution

Async excecution

Async excecution

Suggested solution

enter image description here

3
I haven't used activiti before (I've only used my own bpm implementations), but I think you should be able to accomplish your scenario by creating sequence of: java service task (action 1), java receive task (wait for external event) and java service task (action 2). In order to implement timeout on receive task, you should attach timer boundary event on java receive task. - Sami Korhonen
thanks, one more question - is it possible to implement the length of timeout as variable for process instance or it must be defined in process specification (xml)? - tomas
It is possible, the timer time can be an expression like ${someVar}, or even a bean like ${someBean.calculateTimeout()} - Joram Barrez

3 Answers

3
votes

What you need between Action 1 and 2 is a 'receive task': see http://activiti.org/userguide/index.html#bpmnReceiveTask. The engine will not continue unless an API call is done (runtimeService.signal in v5, runtimeService.trigger in v6). Add a timer boundary event (as on the third picture), to make sure the process instanc

2
votes

You can use the EventBasedGateway, which will wait until a message comes in or until the timer triggers after one minute. Based on the event the corresponding sequence flow will be used and the next activity is executed.

EventBasedGateway

See the documenation for more information about the EventBasedGateway.

0
votes

Another option would be to wrap the message receive event and Action 2 in an embedded sub process with a boundary timer event