When is it okay for an activity to not be idempotent?

Thinking out loud a bit:

  • When the workflow does retry itself with different arguments or “at most once” is the desired behavior.
  • When invoking multiple times isn’t the end of the world e.g. sending an email/SMS
1 Like

Great question. Maybe it’s implicit but if the Activity does not mutate state it can be run an infinite number of times.

1 Like

Even if the activity failed the error handling logic in the workflow is guaranteed to run

The problem is that “at most once” means that activity might not run but return a timeout. In this case, the workflow can:

  • not retry the activity practically losing it
  • retry (which requires it to be idempotent)
  • run some other activity

In some rare cases, losing is OK for some nonessential notification activities.
Idempotency is usually preferred.
Another activity sometimes is used mostly to cleanup possible state changes from the failed activity.