We have a workflow (with >1 workflow retries) and workflow publishes a message to a topic on successful completion or failure.
Given that we are using workflow retries, ideally we would want to publish an error message only after all the retry attempts are exhausted.
So, our assumption is that when ActivityFailure (after all activity retries are exhausted) is caught in an workflow,
- If non-retryable error, then publish a mesage and fail the workflow
- If retryable error,
- we check if all workflow attempts are exhausted, then publish a message and fail the workflow
- if attempts are not exceeded, then we throw the exception so that workflow will be retried. We will not be publishing a message in this case.
I am not sure if this is a good approach. Are there better ways to handle this?