https://github.com/eddmann/aws-eventbridge-choreographed-saga
Example of an choreographed saga to handle order fulfilment using a Event-Driven Architecture (EDA) via AWS EventBridge.
https://github.com/eddmann/aws-eventbridge-choreographed-saga
Last synced: about 1 year ago
JSON representation
Example of an choreographed saga to handle order fulfilment using a Event-Driven Architecture (EDA) via AWS EventBridge.
- Host: GitHub
- URL: https://github.com/eddmann/aws-eventbridge-choreographed-saga
- Owner: eddmann
- Created: 2024-06-11T07:20:25.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-19T06:30:16.000Z (about 2 years ago)
- Last Synced: 2025-01-23T03:26:41.167Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 409 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Choreographed Saga using AWS EventBridge
Example of an choreographed saga to handle order fulfillment using a Event-Driven Architecture (EDA) via AWS EventBridge.
Inspired by an example found in the [Monolith to Microservices](https://samnewman.io/books/monolith-to-microservices/) book.
Events are published in [CloudEvents](https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md) [structured mode](https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md#message) message format.

## Bounded Contexts
- Order
- Warehouse
- Payment
- Loyalty
## Events
- `order.placed`
- `warehouse.stock-reserved`
- `warehouse.order-shipped`
- `payment.taken`
- `loyalty.points-awarded`
## Happy Path
- Order is placed (via HTTP endpoint).
- Stock is reserved (via SQS FIFO Lambda worker, self-handling deduplication).
- Payment is taken (via SQS Lambda worker, handles deduplication within the service).
- Loyalty points are awarded (via internal Loyalty Event Bus, direct Lambda invocation and handling deduplication within the service).
- Order is shipped (via SQS FIFO Lambda worker, self-handling deduplication).
- Order notifications API endpoint is subsequently then notified of the shipped order.
All events emitted on the Global Events Bus can be observed via:
- The SQS local polling worker (`QUEUE=sqs_arn node ./observability-polling-worker/app.js`).
- The CloudWatch Logs integration.
## TODO
- Look at examples of out-of-order processing (domain-specific saga patterns and time-based buffer windows).
- Look into Event Catalogues and Event Schema Definitions.
- Look into unhappy paths and how to 'rollback' the saga.
## Resources
- https://aws.amazon.com/blogs/compute/sending-and-receiving-cloudevents-with-amazon-eventbridge/
- https://serverlessland.com/event-driven-architecture/idempotency
- https://serverlessland.com/event-driven-architecture/ordering