2

I'm using a durable function that's triggered off a queue. I'm sending messages off the queue to a service that is pretty flaky, so I set up the RetryPolicy. Even still, I'd like to be able to see the failed messages even if the max retries has been exhausted.

Do I need to manually throw those to a dead-letter queue (and if so, it's not clear to me how I know when a message has been retried any number of times), or will the function naturally throw those to some kind of dead-letter/poison queue?

jemtan990
  • 443
  • 1
  • 6
  • 22

1 Answers1

2

When an activity fails in Durable Functions, an exception is marshalled back to the orchestration with FunctionFailedException thrown. It doesn't matter whether you used automatic retry or not - at the very end, the whole activity fails and it's up to you to handle the situation. As per documentation:

try
{
    await context.CallActivityAsync("CreditAccount",
        new
        {
            Account = transferDetails.DestinationAccount,
            Amount = transferDetails.Amount
        });
}
catch (Exception)
{
    // Refund the source account.
    // Another try/catch could be used here based on the needs of the application.
    await context.CallActivityAsync("CreditAccount",
        new
        {
            Account = transferDetails.SourceAccount,
            Amount = transferDetails.Amount
        });
}

The only thing retry changes is handling the transient error(so you do not have to enable the safe route each time you have e.g. network issues).

kamil-mrzyglod
  • 4,948
  • 1
  • 20
  • 29