error-handlingaws-lambdaamazon-sqsbref

How could a SQS worker written with bref signal a retry?


After setting batchSize: 1 how should the worker indicate success and how should it indicate temporary failure / ask for a retry? I read https://docs.aws.amazon.com/lambda/latest/dg/invocation-retries.html but it obviously doesn't cover a custom runtime and it's not at all clear what's happening and it doesn't talk about SQS anyways. I suspect just throwing an exception might be enough but I can't make heads or tails as to what signals Lambda.

Tutorials like https://medium.com/cs-code/setup-queue-with-serverless-laravel-using-bref-92b2cd803bb7 make no mention of this. It talks about maxReceiveCount: 3 but not about how to make SQS retry later.


Solution

  • According to the bref maintainer:

    Hey, yes that's exactly that: throw an exception in the handler and let it bubble up to Bref (which will bubble up to Lambda and then SQS).

    https://github.com/brefphp/bref/discussions/911