简体   繁体   中英

Long running activiti service task

We have a lot of automated tasks in a activiti process which takes a lot of time to complete. Like REST calls to external system OR JMS message send and receive response.

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. 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. Certainly you can throw a BPMNError which will bubble up but it makes the actual logic harder to follow.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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