Пример #1
0
 public EnvelopeQuarantine(IEnvelopeStreamer streamer,
     TypedMessageSender writer, IStreamContainer root)
 {
     _streamer = streamer;
     _writer = writer;
     _root = root;
     _root.Create();
 }
Пример #2
0
 public EnvelopeQuarantine(IEnvelopeStreamer streamer,
                           TypedMessageSender writer, IStreamContainer root)
 {
     _streamer = streamer;
     _writer   = writer;
     _root     = root;
     _root.Create();
 }
Пример #3
0
        public Container Build()
        {
            var appendOnlyStore = CreateTapes(TapesContainer);
            var messageStore    = new MessageStore(appendOnlyStore, Streamer.MessageSerializer);

            var toCommandRouter      = new MessageSender(Streamer, CreateQueueWriter(RouterQueue));
            var toFunctionalRecorder = new MessageSender(Streamer, CreateQueueWriter(FunctionalRecorderQueue));
            var toEventHandlers      = new MessageSender(Streamer, CreateQueueWriter(EventProcessingQueue));

            var sender = new TypedMessageSender(toCommandRouter, toFunctionalRecorder);

            var store = new EventStore(messageStore);

            var quarantine = new EnvelopeQuarantine(Streamer, sender, Streaming.GetContainer(ErrorsContainer));

            var builder = new CqrsEngineBuilder(Streamer, quarantine);

            var events   = new RedirectToDynamicEvent();
            var commands = new RedirectToCommand();
            var funcs    = new RedirectToCommand();


            builder.Handle(CreateInbox(EventProcessingQueue), aem => CallHandlers(events, aem), "watch");
            builder.Handle(CreateInbox(AggregateHandlerQueue), aem => CallHandlers(commands, aem));
            builder.Handle(CreateInbox(RouterQueue), MakeRouter(messageStore), "watch");
            // multiple service queues
            _serviceQueues.ForEach(s => builder.Handle(CreateInbox(s), aem => CallHandlers(funcs, aem)));

            builder.Handle(CreateInbox(FunctionalRecorderQueue), aem => RecordFunctionalEvent(aem, messageStore));
            var viewDocs  = CreateDocs(ViewStrategy);
            var stateDocs = new NuclearStorage(CreateDocs(DocStrategy));



            var vector = new DomainIdentityGenerator(stateDocs);
            //var ops = new StreamOps(Streaming);
            var projections = new ProjectionsConsumingOneBoundedContext();

            // Domain Bounded Context
            DomainBoundedContext.EntityApplicationServices(viewDocs, store, vector).ForEach(commands.WireToWhen);
            DomainBoundedContext.FuncApplicationServices().ForEach(funcs.WireToWhen);
            DomainBoundedContext.Ports(sender).ForEach(events.WireToWhen);
            DomainBoundedContext.Tasks(sender, viewDocs, true).ForEach(builder.AddTask);
            projections.RegisterFactory(DomainBoundedContext.Projections);

            // Client Bounded Context
            projections.RegisterFactory(ClientBoundedContext.Projections);

            // wire all projections
            projections.BuildFor(viewDocs).ForEach(events.WireToWhen);

            // wire in event store publisher
            var publisher = new MessageStorePublisher(messageStore, toEventHandlers, stateDocs, DoWePublishThisRecord);

            builder.AddTask(c => Task.Factory.StartNew(() => publisher.Run(c)));

            return(new Container
            {
                Builder = builder,
                Setup = this,
                SendToCommandRouter = toCommandRouter,
                MessageStore = messageStore,
                ProjectionFactories = projections,
                ViewDocs = viewDocs,
                Publisher = publisher,
                AppendOnlyStore = appendOnlyStore
            });
        }