public void A_batch_consumer_should_be_delivered_messages() { var batchConsumer = new TestBatchConsumer <IndividualBatchMessage, Guid>(x => PipelineViewer.Trace(_pipeline)); _pipeline.Subscribe(batchConsumer); PublishBatch(_pipeline, 1); TimeSpan _timeout = 5.Seconds(); batchConsumer.ShouldHaveReceivedBatch(_timeout); }
protected override void ConfigureRabbitMqReceiveEndpoint(IRabbitMqReceiveEndpointConfigurator configurator) { _consumer = new TestBatchConsumer(GetTask <Batch <PingMessage> >()); configurator.PrefetchCount = 10; configurator.Batch <PingMessage>(x => { x.MessageLimit = 5; x.Consumer(() => _consumer); }); }
public void for_batch_subscriptions() { _subscriptionEvent.Expect(x => x.SubscribedTo<IndividualBatchMessage>()).Return(() => { _unsubscribe(); return true; }); var consumer = new TestBatchConsumer<IndividualBatchMessage, Guid>(); _pipeline.Subscribe(consumer); _subscriptionEvent.VerifyAllExpectations(); }
public void for_batch_subscriptions() { _subscriptionEvent.Expect(x => x.SubscribedTo <IndividualBatchMessage>()).Return(() => { _unsubscribe(); return(true); }); var consumer = new TestBatchConsumer <IndividualBatchMessage, Guid>(); _pipeline.Subscribe(consumer); _subscriptionEvent.VerifyAllExpectations(); }
protected override void ConfigureGrpcReceiveEndpoint(IGrpcReceiveEndpointConfigurator configurator) { _consumer = new TestBatchConsumer(GetTask <Batch <PingMessage> >(), GetTask <Batch <PingMessage> >()); configurator.ConcurrentMessageLimit = 5; configurator.Batch <PingMessage>(x => { x.MessageLimit = 10; x.TimeLimit = TimeSpan.FromSeconds(1); x.Consumer(() => _consumer); }); }
public void A_batch_component_should_be_delivered_messages() { var consumer = new TestBatchConsumer<IndividualBatchMessage, Guid>(); _builder.Stub(x => x.GetInstance<TestBatchConsumer<IndividualBatchMessage, Guid>>()).Return(consumer); _pipeline.Subscribe<TestBatchConsumer<IndividualBatchMessage, Guid>>(); PipelineViewer.Trace(_pipeline); PublishBatch(_pipeline, 1); TimeSpan _timeout = 5.Seconds(); TestBatchConsumer<IndividualBatchMessage, Guid>.AnyShouldHaveReceivedBatch(_batchId, _timeout); }
public void A_batch_component_should_be_delivered_messages() { var consumer = new TestBatchConsumer <IndividualBatchMessage, Guid>(); _builder.Stub(x => x.GetInstance <TestBatchConsumer <IndividualBatchMessage, Guid> >()).Return(consumer); _pipeline.Subscribe <TestBatchConsumer <IndividualBatchMessage, Guid> >(); PipelineViewer.Trace(_pipeline); PublishBatch(_pipeline, 1); TimeSpan _timeout = 5.Seconds(); TestBatchConsumer <IndividualBatchMessage, Guid> .AnyShouldHaveReceivedBatch(_batchId, _timeout); }
protected void RunTest() { var batchConsumer = new TestBatchConsumer<IndividualBatchMessage, Guid>(); RemoteBus.Subscribe(batchConsumer); Guid batchId = Guid.NewGuid(); for (int i = 0; i < _batchSize; i++) { IndividualBatchMessage message = new IndividualBatchMessage(batchId, _batchSize); LocalBus.Publish(message); } batchConsumer.ShouldHaveReceivedBatch(_timeout); }
public void A_batch_consumer_should_be_delivered_a_lot_of_messages() { var batchConsumer = new TestBatchConsumer<IndividualBatchMessage, Guid>(x => PipelineViewer.Trace(_pipeline)); var removeSubscription = _pipeline.Subscribe(batchConsumer); PipelineViewer.Trace(_pipeline); PublishBatch(_pipeline, 100); TimeSpan _timeout = 5.Seconds(); batchConsumer.ShouldHaveReceivedBatch(_timeout); removeSubscription(); PipelineViewer.Trace(_pipeline); }
public void for_batch_subscriptions_but_not_when_another_exists() { _subscriptionEvent.Expect(x => x.SubscribedTo <IndividualBatchMessage>()).Repeat.Twice().Return(() => { _unsubscribe(); return(true); }); var consumer = new TestBatchConsumer <IndividualBatchMessage, Guid>(); var token = _pipeline.Subscribe(consumer); var consumerB = new TestBatchConsumer <IndividualBatchMessage, Guid>(); var tokenB = _pipeline.Subscribe(consumerB); token(); _subscriptionEvent.VerifyAllExpectations(); _unsubscribe.AssertWasNotCalled(x => x()); }
protected override Task Arrange() { _batchConsumer = new TestBatchConsumer(Harness.GetTask <Batch <SubmitOrder> >()); var batchOptions = new BatchOptions { MessageLimit = 20, TimeLimit = TimeSpan.FromSeconds(20) }; Harness.Consumer(() => _batchConsumer, configurator => { configurator.Options(batchOptions); }); Harness.OnConfigureReceiveEndpoint += x => { batchOptions.Configure(Harness.InputQueueName, x); }; return(Task.CompletedTask); }
protected void BatchConsume(int runNum) { StartProducers(); var producerCounts = new int[numberOfProducers]; var stopWatch = new Stopwatch(); stopWatch.Start(); IBatchConsumer<int> consumer = new TestBatchConsumer(producerCounts); queue.BatchTake(repetitions * numberOfProducers, consumer); stopWatch.Stop(); double durationMs = stopWatch.Elapsed.TotalMilliseconds; var opsPerSec = Convert.ToInt64(repetitions*numberOfProducers*1000L/durationMs); Console.WriteLine("Run {0} - {1} producers: duration {2}(ms) , {3} ops/sec\n", runNum, numberOfProducers, durationMs, opsPerSec.ToString("N")); foreach (var producerCount in producerCounts) { Assert.AreEqual(repetitions, producerCount); } }
public void for_batch_subscriptions_but_not_when_another_exists() { _subscriptionEvent.Expect(x => x.SubscribedTo<IndividualBatchMessage>()).Repeat.Twice().Return(() => { _unsubscribe(); return true; }); var consumer = new TestBatchConsumer<IndividualBatchMessage, Guid>(); var token = _pipeline.Subscribe(consumer); var consumerB = new TestBatchConsumer<IndividualBatchMessage, Guid>(); var tokenB = _pipeline.Subscribe(consumerB); token(); _subscriptionEvent.VerifyAllExpectations(); _unsubscribe.AssertWasNotCalled(x => x()); }
// [ExpectedException(typeof(SemaphoreFullException))] //TODO: Bad Exception public void The_batch_should_throw_an_error() { _batchSize = 1; var timeoutConsumer = new TestMessageConsumer<BatchTimeout<IndividualBatchMessage, Guid>>(); RemoteBus.Subscribe(timeoutConsumer); var batchConsumer = new TestBatchConsumer<IndividualBatchMessage, Guid>(); RemoteBus.Subscribe(batchConsumer); Guid batchId = Guid.NewGuid(); IndividualBatchMessage message = new IndividualBatchMessage(batchId, _batchSize); LocalBus.Publish(message); LocalBus.Publish(message); }
public void The_batch_should_throw_an_exception_that_the_timeout_occurred() { _batchSize = 2; var timeoutConsumer = new TestMessageConsumer<BatchTimeout<IndividualBatchMessage, Guid>>(); RemoteBus.Subscribe(timeoutConsumer); var batchConsumer = new TestBatchConsumer<IndividualBatchMessage, Guid>(); RemoteBus.Subscribe(batchConsumer); Guid batchId = Guid.NewGuid(); IndividualBatchMessage message = new IndividualBatchMessage(batchId, _batchSize); LocalBus.Publish(message); timeoutConsumer.ShouldHaveReceivedMessage(new BatchTimeout<IndividualBatchMessage, Guid>(batchId), _timeout); batchConsumer.ShouldNotHaveCompletedBatch(TimeSpan.Zero); }