Perform Batch API calls using workflows

We have a requirement as to perform batch operations such as making external API calls for entries passed in a request. We need to guarantee that all API calls would go through and not fail and only failed API calls needs to be retried, not all. So for such a scenario would child workflows come into use. Where each call would create a child workflow to do changes and handle retries based on failure. Is this a good approach to look at? Are we able to check the state of the child workflow to help show on the UI the progress of the batch operation?


I don’t think you need child workflows in this case. The service retries activities according to their retry options. So you just start all these activities in parallel and wait for all of them to complete.

So is this possible with same activity method being executed for each? Are there examples where I could have a look? Thanks for the reply

1 Like

What if we 2 methods that needs to be invoked and the second method depends on the first method result? @maxim

Please don’t ping specific people.

Promise has callback interface similar to CompletableFuture. So you can call promise.handle to chain multiple calls.

Another option is to use Async.function to start multiple parallel threads. Note that having too many blocked parallel threads in a workflow might affect the worker performance negatively.

Is there an example I could follow?

I don’t think there is a good sample for this. Try finding CompletableFuture samples.

1 Like