简体   繁体   English

长时间运行的activiti服务任务

[英]Long running activiti service task

We have a lot of automated tasks in a activiti process which takes a lot of time to complete.我们在一个 activiti 过程中有很多自动化任务,这需要花费大量时间才能完成。 Like REST calls to external system OR JMS message send and receive response.像 REST 调用外部系统或 JMS 消息发送和接收响应。

I can do this using two options:我可以使用两个选项来做到这一点:

  1. Service Async task服务异步任务
  2. Send - receive task: Here we can have one task which will call the external program with correlation id as execution id and move to the next step which would be a receive task.发送 - 接收任务:这里我们可以有一个任务,它将以相关 ID 作为执行 ID 调用外部程序,然后进入下一步,这将是一个接收任务。 Once we get a response from the external system we can signal the process.一旦我们从外部系统获得响应,我们就可以向该过程发出信号。

Can someone validate what would be the correct approach or any better way to handle this in activiti.有人可以验证在活动中处理这个问题的正确方法或更好的方法吗?

If you have control over the receiver services, you could also use an intermediate message event to pause execution and have the external (long running) service release the process by injecting a message.如果您可以控制接收器服务,您还可以使用中间消息事件来暂停执行,并让外部(长期运行的)服务通过注入消息来释放进程。

Your two approaches each have advantages/disadvantages您的两种方法各有优缺点

Service Async Task - I am assuming you are proposing to keep the "pause" logic inside the service task and simply block on the task until the external service comes back.服务异步任务 - 我假设您建议将“暂停”逻辑保留在服务任务中,并简单地阻止该任务,直到外部服务返回。 While this is neater and keeps the logic inside the service task implementation, it doesn't allow for boundary timer events or other BPMN error/timeout handling to move the process on if the service timesout.虽然这更简洁并且将逻辑保留在服务任务实现中,但它不允许边界计时器事件或其他 BPMN 错误/超时处理在服务超时时继续处理流程。 Certainly you can throw a BPMNError which will bubble up but it makes the actual logic harder to follow.当然,你可以抛出一个 BPMNError,它会冒泡,但它会使实际逻辑更难遵循。

Send-Receive Tasks - This assumes you have control over the external services as it is very similar to the third option I mentioned using intermediate message events.发送接收任务 - 这假设您可以控制外部服务,因为它与我提到的使用中间消息事件的第三个选项非常相似。 I tend to prefer this approach as the logic is clear and obvious.我倾向于更喜欢这种方法,因为逻辑清晰明了。 However, it does mean you must have the ability for the external service to "send" something back to the receive task to progress the flow.但是,这确实意味着您必须有能力让外部服务将某些内容“发送”回接收任务以推进流程。

Either way, both options have their place and much depends on the nature of your external service.无论哪种方式,这两种选择都有自己的位置,很大程度上取决于您的外部服务的性质。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM