Giter Site home page Giter Site logo

eugene-khyst / postgresql-event-sourcing Goto Github PK

View Code? Open in Web Editor NEW
1.0K 1.0K 88.0 1.64 MB

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.

License: Apache License 2.0

Java 99.43% PLpgSQL 0.57%
cqrs ddd event-driven event-driven-architecture event-sourcing event-store eventsourcing postgres postgres-notifications postgresql solution-architecture

postgresql-event-sourcing's Introduction

Hi there ๐Ÿ‘‹

My name is Eugene Khyst. I am a Principal Software Engineer and Software Architect and creator of ArtistAssistApp - the best painting and drawing assistant app ๐ŸŽจ๐Ÿ–Œ๏ธ

LinkedIn profile URL

GitHub followers GitHub user's stars

Stack Exchange reputation

Favorite tech stack

Java Spring Boot

JavaScript TypeScript Node.js NestJS React Ant Design Next.js Tailwind CSS

Apache Kafka RabbitMQ PostgreSQL Redis

Docker Kubernetes Nginx

Prometheus Grafana

Mocha TestCafe k6

Favorite methodologies

Agile Kanban Lean

postgresql-event-sourcing's People

Contributors

eugene-khyst avatar tjuerge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postgresql-event-sourcing's Issues

Separate ES-related infrastructure code from application code

Currently the application code is entangled with the generic ES-related infrastructure code, e.g. the enums EventType and AggregateType are pulling-in domain-specific code into the generic EventRegistryand AggregateRegistry implementations.

For a simple example this is ok, but for a template of a production-grade application this could be improved - maybe by aligning to the architecture approach of Clean Architecture (as Tom Hombergs describes it in his blog post Hexagonal Architecture with Java and Spring and his book Get Your Hands Dirty on Clean Architecture ).

So I would like to suggest refactoring the ES-related infrastructure code from the application into it's own package or module.

Build Spring Boot image for arm64 architecture

In case someone is running this project on a M1/M2 Apple chip, this will enable building the image for the correct architecture:

Replace the jib configuration from the build.gradle file from event-sourcing-app with:

jib {
    to {
        image = "eugene-khyst/postgresql-event-sourcing:${project.version}"
    }
    from {
        image = "eclipse-temurin:21-jre"
        platforms {
            platform {
                architecture = 'arm64'
                os = 'linux'
            }
        }
    }
}

Does this work with two writers?

Let's say I have two instances of the service. Both services are creating events. When using postgres, it's possible for there to be gaps in the bigserial id used for the event table.

For example, it's possible for there to be visible id's 0, 1, 3, 4, 5 while the other service is still in the process of getting an event committed with id 2.

My project may also be interesting

Hi,

first of all, awesome work :-)

couldn't find your e-mail address, but I'm working on a (bi)temporal DBS[1] in my spare time, which basically also tracks changes and stores the results of CRUD operations, creating new revisions on each trx commit by appending data to an indexed log (thus, also no WAL is needed -- also due to the limitation of a singe writer per resource).

It avoids long chains of having to apply incremental deltas with intermittant snapshots through a sliding snapshot algorithm.

You can't alter the history, but of course revert to an old revision, add commit messages, track changes to specific nodes or even subtrees, as it optionally stores a rolling hash...

Thought since a couple of years, that it kind of brings temporal "tables" (binary JSON resources actually) and event stores one step closer.

Kind regards and a nice week
Johannes

[1] https://github.com/sirixdb/sirix | https://sirix.io | https://sirix.io/docs/concepts.html

Adopt aspects from Eventuous (The Right Way)

I really like your fully end-to-end approach with its thorough design and documentation. Great work.

But I would love to see in your solution the adoption of some aspects of Alexey Zimarevs The Right Way and its C# library Eventuous, e.g.

How to handle incomming integration events?

Thank you very much @eugene-khyst ! Especially the paragraph about Domain events vs Integration events was an eye-opener.

I am currently wondering how replaying of events works and how the system state can be reliably recreated (conceptually). A reason to do that might be an added or modified projection (e.g. to add another column in a table providing extra information which can be extrapolated from existing events).

This seems to be strait forward when only internal domain events contribute to the aggregate's state. We simply drop the table(s) belonging to the projection, then pipe all historic events through the new/changed event handler of the projection and finally continue to feed new events synchronously.

But, can't we also have aggregates that perform state changes due to incoming integration events? (I am unsure if this is conceptually correct.)

How would we deal with incoming integration events in this case? In order to be able to replay events later, it seems to me, that the incoming events need to be enqueued into the event store along with the internal domain events, because only then we are able to preserve their exact order of processing relative to the internal events.

So in this case we had some process receiving incoming integration events. First, it sticks them into the event store (while dropping repeatedly delivered events). Then it hands them over to synchronous event processing (but not asynchronous forwarding). Finally, it acknowledges the reception to the event broker.

Does this sound valid or is there a better pattern? I am thankful for every comment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.