public void When_a_group_is_prepared_with_three_batches_and_SC_is_restarted_while_the_first_group_is_being_forwarded_then_the_count_still_matches() { var retryManager = new RetryOperationManager(); RetryOperationManager.Operations = new Dictionary <string, RetryOperation>(); using (var documentStore = InMemoryStoreBuilder.GetInMemoryStore()) { CreateAFailedMessageAndMarkAsPartOfRetryBatch(documentStore, retryManager, "Test-group", true, 2001); new RetryBatches_ByStatus_ReduceInitialBatchSize().Execute(documentStore); var testBus = new TestBus(); var sender = new TestSender(); var bodyStorage = new RavenAttachmentsBodyStorage { DocumentStore = documentStore }; var settingsHolder = new NServiceBus.Settings.SettingsHolder(); settingsHolder.Set("EndpointName", "TestEndpoint"); var configure = new Configure(settingsHolder, new TestContainer(), new List <Action <NServiceBus.ObjectBuilder.IConfigureComponents> >(), new NServiceBus.Pipeline.PipelineSettings(new BusConfiguration())); var processor = new RetryProcessor(sender, testBus, new TestReturnToSenderDequeuer(bodyStorage, sender, documentStore, testBus, configure), retryManager); documentStore.WaitForIndexing(); using (var session = documentStore.OpenSession()) { processor.ProcessBatches(session, CancellationToken.None); // mark ready session.SaveChanges(); // Simulate SC restart retryManager = new RetryOperationManager(); RetryOperationManager.Operations = new Dictionary <string, RetryOperation>(); var documentManager = new CustomRetryDocumentManager(false, documentStore) { RetryOperationManager = retryManager }; documentManager.RebuildRetryOperationState(session); processor = new RetryProcessor(sender, testBus, new TestReturnToSenderDequeuer(bodyStorage, sender, documentStore, testBus, configure), retryManager); processor.ProcessBatches(session, CancellationToken.None); session.SaveChanges(); } var status = retryManager.GetStatusForRetryOperation("Test-group", RetryType.FailureGroup); Assert.AreEqual(2001, status.TotalNumberOfMessages); } }
public void When_a_group_is_processed_it_is_set_to_the_Preparing_state() { var retryManager = new RetryOperationManager(); RetryOperationManager.Operations = new Dictionary <string, RetryOperation>(); using (var documentStore = InMemoryStoreBuilder.GetInMemoryStore()) { CreateAFailedMessageAndMarkAsPartOfRetryBatch(documentStore, retryManager, "Test-group", true, 1); var status = retryManager.GetStatusForRetryOperation("Test-group", RetryType.FailureGroup); Assert.AreEqual(RetryState.Preparing, status.RetryState); } }
public void When_a_group_has_one_batch_out_of_two_forwarded_the_status_is_Forwarding() { var retryManager = new RetryOperationManager(); RetryOperationManager.Operations = new Dictionary <string, RetryOperation>(); using (var documentStore = InMemoryStoreBuilder.GetInMemoryStore()) { CreateAFailedMessageAndMarkAsPartOfRetryBatch(documentStore, retryManager, "Test-group", true, 1001); var bodyStorage = new RavenAttachmentsBodyStorage { DocumentStore = documentStore }; var testBus = new TestBus(); var sender = new TestSender(); var settingsHolder = new NServiceBus.Settings.SettingsHolder(); settingsHolder.Set("EndpointName", "TestEndpoint"); var configure = new Configure(settingsHolder, new TestContainer(), new List <Action <NServiceBus.ObjectBuilder.IConfigureComponents> >(), new NServiceBus.Pipeline.PipelineSettings(new BusConfiguration())); var processor = new RetryProcessor(sender, testBus, new TestReturnToSenderDequeuer(bodyStorage, sender, documentStore, testBus, configure), retryManager); documentStore.WaitForIndexing(); using (var session = documentStore.OpenSession()) { processor.ProcessBatches(session, CancellationToken.None); // mark ready session.SaveChanges(); processor.ProcessBatches(session, CancellationToken.None); session.SaveChanges(); } var status = retryManager.GetStatusForRetryOperation("Test-group", RetryType.FailureGroup); Assert.AreEqual(RetryState.Forwarding, status.RetryState); } }