cancel
Showing results for 
Search instead for 
Did you mean: 

Wait for a certain Task to finish without polling

luckybtard
Champ in-the-making
Champ in-the-making
Hello,

i have the following Scenario:

There is a relatively complex Process i implemented using the Activitiengine. it consists of roughly 12 Tasks. Lets assume they are all in sequence for simplicity.

1) A User requests POST to the RESTfull Webservice at: "/rest/start".
2) The Servlet starts a Processinstance with the parameters supplied.
3) The User is obviously waiting for a reply from the Webserver, this reply can be formed right after Task #3 of the 12 is finished.

My implementation at the moment is:
Insert a Usertask after Task #3 that consists of a Form with the reply-parameters, all read-only. (Task #1-#3 are input-checks of sorts)
The Servlet that started the Process, polls the Engine for this Task with the given Businesskey (ever 100ms it checks if the Task "Userreply" is present in the Processinstance with given Businesskey).
If the Task is present, the values are read and the reply for the User is built and sent. Then the Servlet submits the Form and the Process continues.

I do not like this solution, because i don't like the look of Thread.sleep(100), it is unclean, error prone and bound to result in all sorts of wierd raceconditions, once the Service goes online.

My Question is:
Are there any ideas on how to solve this without polling the Engine? Even a type of http-like "Long-polling" would be an improvement for me, unfortunately i don't know how to do it with Activiti

My ideas so far:
1) let the Client poll a status resource for the wanted results, but this only shift the polling to another location.
2) handle Task #1-#3 outside the Processengine, which would take the advantage of the engine


Thanks for any further input!
3 REPLIES 3

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

The Servlet that started the Process, polls the Engine for this Task with the given Businesskey (ever 100ms it checks if the Task "Userreply" is present in the Processinstance with given Businesskey).

Question:
Is it possible to send results from the process instance execution to the servlet again? (e.g. web service task….)

Regards
Martin

exactly my question, can i somehow tell the Servlet to just wait for an answer, without sleeping for fixed time or polling. Something like
xyz.waitForTaskToPopUp("#3")

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

I would say that:
1. you can implement web service and deploy it on your tomcat instance.
2. You can call web service from the process instance (doc: 8.5.4. Web Service Task)

Regards
Martin