Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get and pass all events from event store to node-cqrs-eventdenormalizer #104

Closed
josh0707 opened this issue Mar 19, 2017 · 4 comments
Closed

Comments

@josh0707
Copy link

Hello,

Thank you for your library.
The issue concerns how node-eventstore transmits events to node-cqrs-eventdenormalizer.

I want to rebuild a viewmodel by extracting all the events from the store.

For eventdenormalizer I can do:
eventdenormalizer.clear(function(err) {}); eventdenormalizer.replay([/* ordered array of events */], function (err) { if (err) { console.log(err); } });

For node-eventstore I can use to fetch all the events:
es.getEvents()

However, I didn't find the solution to pass my events from the event store to my eventdenormalizer.
Do I need to use eventstore.setEventToDispatched() for each event or is there another way?

Thanks.

Josh

@adrai
Copy link
Contributor

adrai commented Mar 19, 2017

It depends on your system but basically you need to wrap for example es.getEvents() with a rest service or a dedicated channel on the messageBus.
Then when you want to rebuild you can ask that service to return your events by streaming or I would recommend to implement some sort of pagination...

@josh0707
Copy link
Author

Thanks.
Basically, I could do:
client ---Rest (rebuild request)--> Host Server: rebuild-readmodel method (request events) ---MessageBus--> EventStore (es.getEvents()) ---MessageBus--> Host Server: rebuild-readmodel method (eventdenormalizer.clear();eventdenormalizer.replay())

The rebuild-readmodel method would be accessible via a Rest request to the Host Server and would send a messages to the EventStore to get the events before requesting the Eventdenormalizer to perform a replay.
Does it sound right? ...

@adrai
Copy link
Contributor

adrai commented Mar 19, 2017

There is no correct or incorrect... just do what best fits in your system.
Usually in my systems I do not request for a replay from client side. I do it on the operations side (i.e. while deploying a new release) => so each time a new ReadModel have to be (re)created the denormalizer processes are started with a special environment variable or flag and then they will request all events (in pages) via REST from a "replay-service" that queries the events from the eventstore.

@josh0707
Copy link
Author

Thank you for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants