英文:
How to add delay or Thread.sleep() in script task or how to delay the http task in flowable?
问题
我正在将Flowable Maven依赖项作为Spring Boot项目运行(该项目仅具有Flowable Maven依赖项和BPMN模型)。
还有另一个微服务(包装服务)用于访问Flowable REST API以启动流程和更新任务。
我正在运行一个HTTP任务并将其设置为循环,并不断检查计数。如果计数满足条件,我将结束流程。否则,它将循环执行HTTP任务。用例是,我无法确定何时满足计数条件(甚至可能需要几天)。
在这种情况下,我无法使用Java Service Task。
我该如何处理BPMN模型中的这种情况?或者是否有其他方法可以遵循?请给予建议。
英文:
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.
答案1
得分: 1
你可以让你的检查完成,然后通过一个异或门检查计数是否达到。如果是的话,你可以继续正常的流程。如果不是,你可以继续使用一个中间的定时器事件,在这个事件上定义一个等待时间。在指定的时间之后,令牌将继续,并循环回检查服务任务。只有在循环次数较少的情况下才使用这种方法。如果循环每隔几秒执行一次,潜在地会持续数天,这不是一个好的模式。这将创建一个庞大的实例树和大量的数据库审核信息。在这种情况下,你可以使用外部作业调度程序,如Quartz,以及异步集成模式。
另请参阅:
https://www.flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#timer-intermediate-catching-event
或
https://docs.camunda.io/docs/next/components/modeler/bpmn/timer-events/
英文:
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/
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论