Hi, I'm looking to "gradually" incorporate some of the meteor-space cqrs/eventsourcing stuff you guys have. My current need is pretty light on business logic, but more on the side of needing to update multiple collections (projections) based on something happening. I've been looking at the test_application.coffee and unit tests. It seems realtively straightforward, but one thing that isn't clear to me is how to handle aggregate initialization. It's probably due to other frameworks I've used (e.g. Axon for Java). So just to be clear, to send a command to MyAggregate(id:123). I first need to create a new instance of MyAggregate (using the id), then call .handle(command)?
It's just a little confusing to me, as say Axon,node-cqrs, basically have you just register all your aggregates, then send your commands to a gateway/handler, that then is responsible for routing, instantiation, etc.
As this is an existing app, I can't quite leverage all the cool features you guys seem to have in your full stack. So for now I just need to send commands from my existing code.
@eoliphan: Hi :)
One instance of the
Space.eventSourcing.Router is routing domain commands to all aggregate instances of the some type. For example this is the router that is routing command to instances of
Router has special
initializingMessage attribute and that is the command that instantiates new instances of the aggregate:
Other commands that are routed to the aggregate instances are defined in
Please feel free to ask more questions if you have them. Also take a look at this sample app, it can help you understand how everything is wired up:
This diagram can serve as a cheat sheet for understanding complete, non distributed Space event sourcing infrastructure:
space:testingpackage has a dependency
practicalmeteor:munitand reading the Space docs, it says Space currently only supports testing of package code and recommends this approach.
Hey @fxv, you can use
space:testing with Meteor 1.3 in the same way as with package testing ;)
Please checkout the tests written for the Donations application to get a feeling for it: https://github.com/meteor-space/donations/tree/develop/packages/domain/tests (these are package-tests but it works the same way)
So just include
space:testing space:testing-messaging space:testing-event-sourcing
.meteor/packages file and start testing your event-sourced domain logic in