Tuesday, 31 October 2023

New Show Hacker News story: latest news

Show HN: Light implementation of Event Sourcing using PostgreSQL as event store
2 by eugene-khyst | 0 comments on Hacker News.
Hi everyone, If you have a Java Spring Boot application with a PostgreSQL database, you can implement Event Sourcing without introducing new specialized databases or frameworks. If you have an application dealing with an entity called Order, you should adopt Event Sourcing to keep track of all changes, and know how the Order got into the current state. Event Sourcing gives you: 1. the true history of the system (audit and traceability), 2. the ability to put the system in any prior state (debugging), 3. the ability to create read projections from events as needed to respond to new demands. There are several well-known specialized frameworks and databases for Event Sourcing: EventStoreDB, Marten, Eventuate, to name a few. But adopting a new framework or database you are not familiar with may stop you from trying the Event Sourcing pattern in your project. But you can actually implement Event Sourcing with a few classes and use PostgreSQL as an event store. The "postgresql-event-sourcing" project is a reference implementation of an event-sourced system that uses PostgreSQL as an event store built with Spring Boot. Fork the repository and use it as a template for your projects. Or clone the repository and run end-to-end tests to see how everything works together. The project describes in detail: - database model for storing events, - synchronous and asynchronous event handlers, - CQRS, - Transactional Outbox pattern, - Polling Publisher pattern, - optimized publisher that uses PostgreSQL LISTEN/NOTIFY capabilities, - and more. This project can be easily extended to comply with your domain model. The source code is available on GitHub < https://github.com/eugene-khyst/postgresql-event-sourcing >.

No comments:

Post a Comment