0

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.

chx
  • 11,270
  • 7
  • 55
  • 129

2 Answers2

1

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

chx
  • 11,270
  • 7
  • 55
  • 129
0

I am not sure about custom runtime but in Nodejs if you just throw an error the message is available back in SQS in case no error is thrown it is deleted from SQS.

Configure a dead letter queue for sqs after maxRetryCount, so your message will go to DLQ after retries. After fixing the cause of failures you can move the message from DLQ to your main SQS using another lambda or cli.

SQS will not retry itself as lambda do long polling from SQS.

nirvana124
  • 903
  • 1
  • 9
  • 12
  • " if you just throw an error the message is available back in SQS in case no error is thrown it is deleted from SQS." right, that's the question: how do you do that in a custom runtime? – chx Apr 12 '21 at 05:05
  • In any runtime I think if we throw error Lambda should handle it. You can do a small POC. – nirvana124 Apr 12 '21 at 05:14
  • That "small PoC" would be the answer to this question... I find Lambda very hard to debug. – chx Apr 12 '21 at 05:24