private static IStoreEvents WireupEventStore(IBus bus) { return(Wireup.Init() ////.LogToOutputWindow() ////.LogToConsoleWindow() .UsingInMemoryPersistence() .UsingJsonSerialization() .Compress() .UsingSynchronousDispatchScheduler() .DispatchTo(new DelegateMessageDispatcher(c => MassTransitDispatcher.DispatchCommit(bus, c))) .Build()); }
// Here, I'm wiring up my MemBus instance and telling it how to resolve my subscribers // MemBus also has an awesome way to resolve subscribers from an IoC container. In prod, // I'll wire my subscribers into StructureMap and have MemBus resolve them from there. // I'm also initializing my awesome test client UI which, if you'll recall from way back at the start // simply publishes commands to my MemBus instance (and, again, it could be whatever) public SynchronousDispatchTests() { this.bus = new InProcessBus(DispatchStrategy.Synchronous); #pragma warning disable 0618 this.store = Wireup.Init() .UsingInMemoryPersistence() .UsingSynchronousDispatchScheduler() .DispatchTo(new DelegateMessageDispatcher(c => MassTransitDispatcher.DispatchCommit(this.bus, c))) .Build(); #pragma warning restore 0618 this.repository = new EventStoreRepository(this.store, new AggregateFactory(), new ConflictDetector()); var handler = new CreateAccountCommandHandler(this.repository); this.bus.Subscribe(handler); this.client = new SomeAwesomeUi(this.bus); }