CQRS - how to handle new report tables (or: how to import ALL history from the event store)

前端 未结 3 1753
心在旅途
心在旅途 2021-02-03 10:30

I\'ve studied some CQRS sample implementations (Java / .Net) which use event sourcing as the event store and a simple (No)SQL stores as the \'report store\'.

Looks all g

相关标签:
3条回答
  • 2021-02-03 10:47

    For example in Axon Framework, this can be done via:

    JdbcEventStore eventStore = ...;
    
    ReplayingCluster replayingCluster = new ReplayingCluster(
                new SimpleCluster("replaying"),
                eventStore,
                new NoTransactionManager(),
                0,
                new BackloggingIncomingMessageHandler());
    
    replayingCluster.startReplay();
    

    Event replay is an area that is not completely documented and lacks mature tooling, but here are some starting points:

    • http://www.axonframework.org/docs/2.4/event-processing.html#d5e1852
    • https://groups.google.com/forum/#!searchin/axonframework/ReplayingCluster/axonframework/brCxc7Uha7I/Hr4LJpBJIWMJ
    0 讨论(0)
  • 2021-02-03 10:47

    The 'EventRepository' only contains these methods because you only need them in production.

    When adding a new denormalization for reporting, you can send all event from start to you handler.

    You can do this on your development site this way :

    • Load your event log to the dev site
    • Send all events to your denormalization handler
    • Move your new view + handler to your production site
    • Run events that happened inbetween
    • Now you're ready
    0 讨论(0)
  • 2021-02-03 10:49

    You re-run the handler on the existing event log (eg you play the old events through the new event handler)

    Consider you example ... you have a ton of PhoneCallLoggedEvents in your event log. Take your new Handles and play all the old events through it. It is then like it has always been running and will just continue to process any new events that arrive.

    Cheers,

    Greg

    0 讨论(0)
提交回复
热议问题