iTollu
iTollu

Reputation: 1069

How to implement transactional outbox pattern with AWS Lambda and PostgreSQL

I use AWS Lambda function to respond to HTTP requests.

The function stores some data in a PostgreSQL database. To reliably notify interested parties of the changes, I use transactional outbox pattern.

In scope of the same transaction I store an outgoing message to PostgreSQL. Then SNS client should process outbox in a different transaction.

Ideally processing outbox should happen after I send response to the original HTTP request. The issue is that once response is sent, Lambda function freezes.

One way to work around the freeze is to use Lambda extension. Although, extension lifecycle doesn't have a hook for "Lambda call completed" event.

AWS documentation provides an example for a database that supports change data capture (https://docs.aws.amazon.com/prescriptive-guidance/latest/cloud-design-patterns/transactional-outbox.html). But that is not the case with PostgreSQL.

As of now for simplicity I process outbox before sending response, but I'd like to improve it.

What is the correct approach to use in this case?

Upvotes: 0

Views: 83

Answers (0)

Related Questions