public PersistenceQueue(BlockingCollection <TransactionTask> writerQueue,
                         PublisherEnqueuer publisherEnqueuer,
                         IEventRepository repository)
 {
     _repository        = repository;
     _publisherEnqueuer = publisherEnqueuer;
     _writerQueue       = writerQueue;
 }
Ejemplo n.º 2
0
        public EventStore(IEventRepository repository,
                          IEventPublisher publisher)
        {
            _repository        = repository;
            _publisher         = publisher;
            _writerQueue       = new BlockingCollection <TransactionTask>(BufferSize);
            _publisherQueue    = new BlockingCollection <EventTransaction>(BufferSize);
            _publisherEnqueuer = new PublisherEnqueuer(_publisherQueue);

            //ToDo: Look into using continuation to catch that the task died and recreate it if possible.
            _writerRunner = Task.Factory.StartNew(() => new PersistenceQueue(_writerQueue, _publisherEnqueuer, _repository).Consume(),
                                                  TaskCreationOptions.LongRunning);
            _publisherRunner = Task.Factory.StartNew(() => new PublisherQueue(_publisherQueue, _publisher).Consume(),
                                                     TaskCreationOptions.LongRunning);
        }