Lambda triggered by SQS queue : How to manage errors correctly

0

We are building a conversation engine that could sometimes encounter rate limit when calling an external API. We are currently struggling with the fact that AWS reduce the concurrent run of our lambdas connected to our SQS queues when theses lambdas are failing, because when we encounter a rate limit error, we throw the error for the lambda to fail and wait for the retrying process of the SQS queue.

We searched a way to release gracefully messages in the queue without triggering an error. We found that we could set the visibility timeout of the current processed message to 0, but it seems that the sqs polling system of lambda is deleting the message at the end of the run of our lambda.

Do you have a workaround to enable us to gracefully manage errors in our lambdas and release the message in the queue ?

Thanks !

1 Risposta
0
Risposta accettata

Try using Partial batch responses. In this way you do not fail the Lambda, but you let the Lambda service know that you did not handle a message(s) in the batch.

profile pictureAWS
ESPERTO
Uri
con risposta un mese fa
profile picture
ESPERTO
verificato un mese fa
  • Thanks for you answer, you recommend to use the Partial batch response even if my batch only contains 1 message ? (Because our lambda manage only 1 message a time). Also, it's a fifo queue that is connected to the lambda

  • Should work with both standard and FIFO and with a single message as well.

  • Thanks ! Will try that

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande