public AggregateDispatcher(ITapeStorageFactory factory, IEnvelopeStreamer streamer, string path, QueueWriterRegistry queue) { _factory = factory; _streamer = streamer; _path = path; _queue = queue; }
protected override ITapeStream InitializeAndGetTapeStorage() { var connectionString = Settings.Default.SqlConnectionString; var tableName = Settings.Default.SqlTapeWriterTableName; _storageFactory = new SqlTapeStorageFactory(connectionString, tableName); var count = 0; while (true) { count++; try { _storageFactory.InitializeForWriting(); break; } catch (Exception) { if (count < 1) { System.Threading.Thread.Sleep(500); continue; } throw; } } const string name = "test"; return _storageFactory.GetOrCreateStream(name); }
public static Action <ImmutableEnvelope> Route(Func <string, IQueueWriter> factory, IEnvelopeStreamer serializer, ITapeStorageFactory tapes) { var events = factory(EventsQueue); var timerQueue = factory(TimerQueue); var entityQueue = factory(EntityQueue); var services = factory(ServiceQueue); var log = tapes.GetOrCreateStream(DomainLogName); return(envelope => { var data = serializer.SaveEnvelopeData(envelope); if (!log.TryAppend(data)) { throw new InvalidOperationException("Failed to record domain log"); } if (envelope.DeliverOnUtc > Current.UtcNow) { timerQueue.PutMessage(data); return; } if (envelope.Items.All(i => i.Content is ICommand <IIdentity>)) { entityQueue.PutMessage(data); return; } if (envelope.Items.All(i => i.Content is IEvent <IIdentity>)) { // we can have more than 1 entity event. // all entity events are routed to events as separate for (int i = 0; i < envelope.Items.Length; i++) { var name = envelope.EnvelopeId + "-e" + i; var copy = EnvelopeBuilder.CloneProperties(name, envelope); copy.AddItem(envelope.Items[i]); events.PutMessage(serializer.SaveEnvelopeData(copy.Build())); } return; } if (envelope.Items.Length != 1) { throw new InvalidOperationException( "Only entity commands or entity events can be batched"); } var item = envelope.Items[0].Content; if (item is IFunctionalCommand) { services.PutMessage(data); return; } if (item is IFunctionalEvent || item is ISampleEvent) { events.PutMessage(data); return; } throw new InvalidOperationException(string.Format("Unroutable message {0}", item)); }); }
public AggregateDispatcher(ITapeStorageFactory factory, IEnvelopeStreamer streamer, string path, QueueWriterRegistry queue) { _factory = factory; _streamer = streamer; _path = path; _queue = queue; }
public AggregateFactory(ITapeStorageFactory factory, IEnvelopeStreamer streamer, IQueueWriter writer, NuclearStorage storage, IIdentityGenerator generator) { _factory = factory; _streamer = streamer; _writer = writer; _storage = storage; _generator = generator; }
public static Action<ImmutableEnvelope> Route(Func<string, IQueueWriter> factory, IEnvelopeStreamer serializer, ITapeStorageFactory tapes) { var events = factory(EventsQueue); var timerQueue = factory(TimerQueue); var entityQueue = factory(EntityQueue); var services = factory(ServiceQueue); var log = tapes.GetOrCreateStream(DomainLogName); return envelope => { var data = serializer.SaveEnvelopeData(envelope); if (!log.TryAppend(data)) throw new InvalidOperationException("Failed to record domain log"); if (envelope.DeliverOnUtc > Current.UtcNow) { timerQueue.PutMessage(data); return; } if (envelope.Items.All(i => i.Content is ICommand<IIdentity>)) { entityQueue.PutMessage(data); return; } if (envelope.Items.All(i => i.Content is IEvent<IIdentity>)) { // we can have more than 1 entity event. // all entity events are routed to events as separate for (int i = 0; i < envelope.Items.Length; i++) { var name = envelope.EnvelopeId + "-e" + i; var copy = EnvelopeBuilder.CloneProperties(name, envelope); copy.AddItem(envelope.Items[i]); events.PutMessage(serializer.SaveEnvelopeData(copy.Build())); } return; } if (envelope.Items.Length != 1) { throw new InvalidOperationException( "Only entity commands or entity events can be batched"); } var item = envelope.Items[0].Content; if (item is IFunctionalCommand) { services.PutMessage(data); return; } if (item is IFunctionalEvent || item is ISampleEvent) { events.PutMessage(data); return; } throw new InvalidOperationException(string.Format("Unroutable message {0}", item)); }; }
protected override ITapeStream InitializeAndGetTapeStorage() { _storageFactory = new FileTapeStorageFactory(_path); _storageFactory.InitializeForWriting(); const string name = "test"; return(_storageFactory.GetOrCreateStream(name)); }
protected override ITapeStream InitializeAndGetTapeStorage() { var config = AzureStorage.CreateConfig(_cloudStorageAccount); _storageFactory = new BlobTapeStorageFactory(config, ContainerName); _storageFactory.InitializeForWriting(); const string name = "test"; return _storageFactory.GetOrCreateStream(name); }
protected override ITapeStream InitializeAndGetTapeStorage() { var config = AzureStorage.CreateConfig(_cloudStorageAccount); _storageFactory = new BlobTapeStorageFactory(config, ContainerName); _storageFactory.InitializeForWriting(); const string name = "test"; return(_storageFactory.GetOrCreateStream(name)); }
protected override ITapeStream InitializeAndGetTapeStorage() { var connectionString = Settings.Default.SqlConnectionString; var tableName = Settings.Default.SqlTapeWriterTableName; _storageFactory = new SqlTapeStorageFactory(connectionString, tableName); var count = 0; while (true) { count++; try { _storageFactory.InitializeForWriting(); break; } catch (Exception) { if (count < 1) { System.Threading.Thread.Sleep(500); continue; } throw; } } const string name = "test"; return(_storageFactory.GetOrCreateStream(name)); }
protected override void FreeResources() { _storageFactory = null; _storageFactory = null; }
protected override void FreeResources() { _storageFactory = null; }
protected override ITapeStream InitializeAndGetTapeStorage() { _storageFactory = new FileTapeStorageFactory(_path); _storageFactory.InitializeForWriting(); const string name = "test"; return _storageFactory.GetOrCreateStream(name); }
public void TapeIs(ITapeStorageFactory storage) { _tapeStorage = storage; }
public void TapeIs(ITapeStorageFactory storage) { _tapeStorage = storage; }
public AggregateFactory(ITapeStorageFactory factory, IEnvelopeStreamer streamer, IQueueWriter writer) { _factory = factory; _streamer = streamer; _writer = writer; }
public EventStore(IMessageSender sender, ITapeStorageFactory tapeFactory, IDataSerializer serializer) { this.sender = sender; this.tapeFactory = tapeFactory; this.serializer = serializer; }