camundabpmncamunda-modelerflowable

How to add delay or Thread.sleep() in script task or how to delay the http task in flowable?


I am running flowable maven dependency as a spring boot project (This project has flowable maven dependency and the bpmn model alone).

There is another micro-service (wrapper service) to access the flowable REST APIs to initiate the process and updating the tasks.

I am running a http task and make it as a loop, and keep on checking the count. if the count satisfies, I will end the process. Else, it will loop around the http task. The use case is, I cannot determine when the count will be met.(It might even take days).

Here I cannot have the provision to use Java Service Task.

How can I handle this scenario in bpmn model? or is there any other approach to follow? Please advice.


Solution

  • You can let your check complete, then check with an xor gateway if the count is reached. If yes, you continue with the regular process. If not, you continue with an intermediate timer event on which you define a wait time. After the specified time the token will continue and you loop back into the the checking service task. Only use this approach if you the number of loops will be small. It is not a good patter to use if the loop is executed every few seconds, potentially over days. This it create a large instance tree and much audit information in the DB. In such a case you can work with an external job scheduler such as Quartz and an asynchronous integration pattern.

    Also see:
    https://www.flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#timer-intermediate-catching-event
    or
    https://docs.camunda.io/docs/next/components/modeler/bpmn/timer-events/