AnsweredAssumed Answered

Running workflows asynchronously

Question asked by pmesmeur on Jun 16, 2015
Latest reply on Jun 30, 2015 by pmesmeur

I would like to use Activiti to run workflows that possibly contain long service tasks (that may run for more than one minute). Such workflows would be called via:


However, the method startProcessInstanceByKey() will return/leave only when the long service task will be competed, which is not acceptable. To avoid this unwanted behavior, I have to declare my service task as async. It is tested, it works fine.

Now, I realize that doing so, when I launch workflows having long running tasks, I exit asynchronously, while with workflows not having long running task, I exit quickly but synchronously.

So I am looking for a more consistent approach with which the answer will be always asynchronous. For the moment, I see the following possibilities:
  1. wrapping the call to startProcessInstanceByKey(…) in a thread (I don't like it very much)
  3. making all the service tasks async; isn't it "too much"?
  5. while parsing the BPMN, dynamically/programmatically adding a "dummy" async task after the workflow start point (and after each the user tasks)
I'm sharing my reflection in order to get possible ideas, remarks, feedback on this subjects. According to your experience about it, what do you think of my  propositions? do you have a preferred one? why? Any information is welcomed ;-)

Another point I would like to clarify around async task: is the a difference regarding the database between sync and async task? If yes, do you think it has a high impact on the performance?