Mojo jojo
Mojo jojo

Reputation: 81

Achieving idempotent results with lambda, SQS and DDB

I have an SQS that triggers a lambda. SQS message body basically contains a request ID and that is it. Lambda does some processing and creates a ticket with request ID in the body. The ticket creation is happening by calling an external API. We do not have any control over it. This API responds with the ticket ID. This ticket ID is generated by the external API. And it is a randomly generated UUID. Lambda then updates a DDB table with this ticket ID.

Now, if lambda fails, for any reason, before updating the table and after creating the ticket, the message goes to DLQ. During retries, lambda will fetch the message and read the same request ID and creates a new ticket with the same message body. I will end up with duplicate tickets. How do I achieve idempotent behavior in this scenario?

Upvotes: 0

Views: 71

Answers (0)

Related Questions