cancel
Showing results for 
Search instead for 
Did you mean: 

Running workflows asynchronously

pmesmeur
Champ in-the-making
Champ in-the-making
Hello,

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:

ProcessEngine.getRuntimeService().startProcessInstanceByKey(…);


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)
  2.  
  3. making all the service tasks async; isn't it "too much"?
  4.  
  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?

Regards,
Philippe
11 REPLIES 11

jbarrez
Star Contributor
Star Contributor
"but unfortunately I did not succeed to subscribe pro grammatically to "timeout" signal"

What do you mean here? Of course, the signal needs to be modeled in the process, but is that a problem?

pmesmeur
Champ in-the-making
Champ in-the-making
I was trying obscure things. I won't spent time to explain clearly what I wanted to do, because now that I have a deeper view, I realize that it was not clear at all 😉

My main need was to forward an exception from my Service running in a dedicated thread to the engine. After I wrote my last comment, I found the following page… and it seems that you already know the rest of the story 😉

Philippe