Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Asynchronous Activity vs have workflow wait for signal

Let's say we need to send user an email and wait for user to reply and then continue the workflow. Should we create an async activity to send the email, and when the reply email comes, we complete the activity? Or should we create a normal activity to send the email, and then the workflow await a signal, and when the reply email comes, we send the signal to the workflow? Are these 2 options equivalent? Or there are some difference can be used to decide which one to use for different activities?

Thanks in advance

like image 644
Gordon Sun Avatar asked Sep 11 '25 23:09

Gordon Sun


1 Answers

I recommend the activity then signal approach for this use case. The reason is that sending an email and waiting for a reply are two different tasks with different timeouts and retry policies.

If send email activity fails it is expected to be retried on a short timeout on a pretty tight retry schedule. At the same time the timeout for the user action is expected to be much larger (potentially days or weeks) and is usually not retriable.

Edit to answer the retry question:

But what if we do want to retry? Say we expect the user to reply the email within a day, otherwise we send it again. We can retry the entire workflow but that is not ideal since send email and user reply is only part of the workflow. Should we make it a child workflow and have retry on the child workflow?

You retry the whole interaction. See the fileprocessing example of retrying part of a workflow. Here are Go SDK and Java SDK versions of it.

like image 84
Maxim Fateev Avatar answered Sep 15 '25 19:09

Maxim Fateev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!