Setup Consumers

Last updated at 23 March 2018 | Published at 07 March 2018

In order to process events you need to wire up your consumers to your dispatchers. EventSauce ships with a SynchronousMessageDispatcher which is used for testing, but you can also use it as a regular dispatcher. It’s recommended to use a queueing/async dispatcher for better system resiliency, reliability and general fault-tolerance. However, you’re not blocked from modelling simply because you’re lacking that infrastructure.

Synchronous Message Dispatcher


use EventSauce\EventSourcing\ConstructingAggregateRootRepository;
use EventSauce\EventSourcing\SynchronousMessageDispatcher;

$messageDispatcher = new SynchronousMessageDispatcher(
    new ProjectorOne(),
    new ProjectorTwo(),
    new ProcessManager()

$aggregateRootRepository = new ConstructingAggregateRootRepository(