public ErrorPersister(IDocumentStore store, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher, IEnrichImportedErrorMessages[] enrichers, IFailedMessageEnricher[] failedMessageEnrichers) { this.store = store; this.bodyStorageEnricher = bodyStorageEnricher; this.enrichers = enrichers; failedMessageFactory = new FailedMessageFactory(failedMessageEnrichers); }
public FailedMessagePersister(IDocumentStore store, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher, IEnrichImportedMessages[] enrichers, IFailedMessageEnricher[] failedMessageEnrichers) { this.store = store; this.bodyStorageEnricher = bodyStorageEnricher; this.enrichers = enrichers.Where(x => x.EnrichErrors).ToArray(); failedMessageFactory = new FailedMessageFactory(failedMessageEnrichers); }
public AuditIngestionComponent( Settings settings, IDocumentStore documentStore, RawEndpointFactory rawEndpointFactory, LoggingSettings loggingSettings, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher, IEnrichImportedAuditMessages[] enrichers, AuditIngestionCustomCheck.State ingestionState ) { var errorHandlingPolicy = new AuditIngestionFaultPolicy(documentStore, loggingSettings, FailedMessageFactory, OnCriticalError); auditPersister = new AuditPersister(documentStore, bodyStorageEnricher, enrichers); var ingestor = new AuditIngestor(auditPersister, settings); var ingestion = new AuditIngestion( (messageContext, dispatcher) => ingestor.Ingest(messageContext), dispatcher => ingestor.Initialize(dispatcher), settings.AuditQueue, rawEndpointFactory, errorHandlingPolicy, OnCriticalError); failedImporter = new ImportFailedAudits(documentStore, ingestor, rawEndpointFactory); watchdog = new Watchdog(ingestion.EnsureStarted, ingestion.EnsureStopped, ingestionState.ReportError, ingestionState.Clear, settings.TimeToRestartAuditIngestionAfterFailure, log, "failed message ingestion"); }
public async Task Should_store_body_regardless_of_the_body_size() { var fakeStorage = new FakeBodyStorage(); // previously the max body storage default was larger than 100 KB var enricher = new BodyStorageFeature.BodyStorageEnricher(fakeStorage); const int ExpectedBodySize = 150000; var body = Encoding.UTF8.GetBytes(new string('a', ExpectedBodySize)); await enricher.StoreErrorMessageBody(body, new Dictionary <string, string>(), new Dictionary <string, object>()); Assert.AreEqual(ExpectedBodySize, fakeStorage.StoredBodySize, "Body should never be dropped for error messages"); }
public AuditQueueImport(IBuilder builder, ISendMessages forwarder, IDocumentStore store, CriticalError criticalError, LoggingSettings loggingSettings, Settings settings, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher) { this.builder = builder; this.forwarder = forwarder; this.store = store; this.criticalError = criticalError; this.loggingSettings = loggingSettings; this.settings = settings; this.bodyStorageEnricher = bodyStorageEnricher; enrichers = builder.BuildAll <IEnrichImportedMessages>().Where(e => e.EnrichAudits).ToArray(); }
public ErrorQueueImport(IBuilder builder, ISendMessages forwarder, IDocumentStore store, IBus bus, CriticalError criticalError, LoggingSettings loggingSettings, Settings settings, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher) { this.builder = builder; this.forwarder = forwarder; this.store = store; this.bus = bus; this.criticalError = criticalError; this.loggingSettings = loggingSettings; this.settings = settings; this.bodyStorageEnricher = bodyStorageEnricher; enrichers = builder.BuildAll <IEnrichImportedMessages>().Where(e => e.EnrichErrors).ToArray(); var failedEnrichers = builder.BuildAll <IFailedMessageEnricher>().ToArray(); failedMessageFactory = new FailedMessageFactory(failedEnrichers); }
public async Task Should_remove_body_when_above_threshold() { var fakeStorage = new FakeBodyStorage(); var maxBodySizeToStore = 20000; var settings = new Settings { MaxBodySizeToStore = maxBodySizeToStore }; var enricher = new BodyStorageFeature.BodyStorageEnricher(fakeStorage, settings); var body = Encoding.UTF8.GetBytes(new string('a', maxBodySizeToStore + 1)); await enricher.StoreAuditMessageBody(body, new Dictionary <string, string>(), new Dictionary <string, object>()); Assert.AreEqual(0, fakeStorage.StoredBodySize, "Body should be removed if above threshold"); }
public AuditIngestionComponent( Settings settings, IDocumentStore documentStore, RawEndpointFactory rawEndpointFactory, LoggingSettings loggingSettings, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher, IEnrichImportedAuditMessages[] enrichers, AuditIngestionCustomCheck.State ingestionState ) { this.settings = settings; var errorHandlingPolicy = new AuditIngestionFaultPolicy(documentStore, loggingSettings, FailedMessageFactory, OnCriticalError); auditPersister = new AuditPersister(documentStore, bodyStorageEnricher, enrichers); ingestor = new AuditIngestor(auditPersister, settings); var ingestion = new AuditIngestion( async(messageContext, dispatcher) => { var taskCompletionSource = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously); messageContext.SetTaskCompletionSource(taskCompletionSource); await channel.Writer.WriteAsync(messageContext).ConfigureAwait(false); await taskCompletionSource.Task.ConfigureAwait(false); }, dispatcher => ingestor.Initialize(dispatcher), settings.AuditQueue, rawEndpointFactory, errorHandlingPolicy, OnCriticalError); failedImporter = new ImportFailedAudits(documentStore, ingestor, rawEndpointFactory); watchdog = new Watchdog(ingestion.EnsureStarted, ingestion.EnsureStopped, ingestionState.ReportError, ingestionState.Clear, settings.TimeToRestartAuditIngestionAfterFailure, log, "failed message ingestion"); channel = Channel.CreateBounded <MessageContext>(new BoundedChannelOptions(settings.MaximumConcurrencyLevel) { SingleReader = true, SingleWriter = false, AllowSynchronousContinuations = false, FullMode = BoundedChannelFullMode.Wait }); ingestionWorker = Task.Run(() => Loop(), CancellationToken.None); }
public async Task Should_store_body_in_storage_when_above_large_object_heap_but_below_threshold_and_not_binary() { var fakeStorage = new FakeBodyStorage(); var maxBodySizeToStore = 100000; var settings = new Settings { MaxBodySizeToStore = maxBodySizeToStore }; var enricher = new BodyStorageFeature.BodyStorageEnricher(fakeStorage, settings); var expectedBodySize = BodyStorageFeature.BodyStorageEnricher.LargeObjectHeapThreshold + 1; var body = Encoding.UTF8.GetBytes(new string('a', expectedBodySize)); var metadata = new Dictionary <string, object>(); await enricher.StoreAuditMessageBody(body, new Dictionary <string, string>(), metadata); Assert.AreEqual(expectedBodySize, fakeStorage.StoredBodySize, "Body should be stored if below threshold"); Assert.IsFalse(metadata.ContainsKey("Body")); }
public async Task Should_remove_body_when_above_threshold_and_binary() { var fakeStorage = new FakeBodyStorage(); var maxBodySizeToStore = 20000; var settings = new Settings { MaxBodySizeToStore = maxBodySizeToStore }; var enricher = new BodyStorageFeature.BodyStorageEnricher(fakeStorage, settings); var body = Encoding.UTF8.GetBytes(new string('a', maxBodySizeToStore + 1)); var metadata = new Dictionary <string, object>(); var headers = new Dictionary <string, string> { { Headers.ContentType, "application/binary" } }; await enricher.StoreAuditMessageBody(body, headers, metadata); Assert.AreEqual(0, fakeStorage.StoredBodySize, "Body should be removed if above threshold"); Assert.IsFalse(metadata.ContainsKey("Body")); }
public ErrorIngestionComponent( Settings settings, IDocumentStore documentStore, IDomainEvents domainEvents, RawEndpointFactory rawEndpointFactory, LoggingSettings loggingSettings, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher, IEnrichImportedErrorMessages[] enrichers, IFailedMessageEnricher[] failedMessageEnrichers, ErrorIngestionCustomCheck.State ingestionState ) { var announcer = new FailedMessageAnnouncer(domainEvents); var persister = new ErrorPersister(documentStore, bodyStorageEnricher, enrichers, failedMessageEnrichers); var ingestor = new ErrorIngestor(persister, announcer, settings.ForwardErrorMessages, settings.ErrorLogQueue); var ingestion = new ErrorIngestion(ingestor, settings.ErrorQueue, rawEndpointFactory, documentStore, loggingSettings, OnCriticalError); failedImporter = new ImportFailedErrors(documentStore, ingestor, rawEndpointFactory); watchdog = new Watchdog(ingestion.EnsureStarted, ingestion.EnsureStopped, ingestionState.ReportError, ingestionState.Clear, settings.TimeToRestartErrorIngestionAfterFailure, log, "failed message ingestion"); }
public AuditImporter(IBuilder builder, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher) { this.bodyStorageEnricher = bodyStorageEnricher; enrichers = builder.BuildAll <IEnrichImportedMessages>().Where(e => e.EnrichAudits).ToArray(); }
public AuditPersister(IDocumentStore store, BodyStorageFeature.BodyStorageEnricher bodyStorageEnricher, IEnrichImportedAuditMessages[] enrichers) { this.store = store; this.bodyStorageEnricher = bodyStorageEnricher; this.enrichers = enrichers; }