示例#1
0
        public async Task Should_receive_one_batch_per_group()
        {
            var correlation1 = NewId.NextGuid();
            var correlation2 = NewId.NextGuid();

            await InputQueueSendEndpoint.Send(new PingMessage());

            await InputQueueSendEndpoint.Send(new PingMessage(), Pipe.Execute <SendContext>(ctx => ctx.CorrelationId = correlation1));

            await InputQueueSendEndpoint.Send(new PingMessage(), Pipe.Execute <SendContext>(ctx => ctx.CorrelationId = correlation1));

            await InputQueueSendEndpoint.Send(new PingMessage(), Pipe.Execute <SendContext>(ctx => ctx.CorrelationId = correlation2));

            await InputQueueSendEndpoint.Send(new PingMessage(), Pipe.Execute <SendContext>(ctx => ctx.CorrelationId = correlation2));

            await InputQueueSendEndpoint.Send(new PingMessage(), Pipe.Execute <SendContext>(ctx => ctx.CorrelationId = correlation2));

            await InactivityTask.ContinueWith(t =>
            {
            });

            var count = await BusTestHarness.Consumed.SelectAsync <PingMessage>().Take(6).Count();

            Assert.That(count, Is.EqualTo(6));
            Assert.That(_batches.Select(x => x.Length), Is.EquivalentTo(new[] { 1, 2, 3 }));
        }
示例#2
0
        public async Task Should_fault_once_per_message()
        {
            await InputQueueSendEndpoint.Send(new PingMessage());

            await InputQueueSendEndpoint.Send(new PingMessage());

            await InactivityTask.ContinueWith(t =>
            {
            });

            Assert.That(_individualFaults, Is.EqualTo(2));
            Assert.That(_batchFaults, Is.EqualTo(0));
        }
示例#3
0
        public async Task Should_stop_after_limit_exceeded()
        {
            var pingId = NewId.NextGuid();

            _attempts[pingId] = 0;

            Task <ConsumeContext <Fault <PingMessage> > > handler =
                ConnectPublishHandler <Fault <PingMessage> >(context => context.Message.Message.CorrelationId == pingId);

            await Bus.Publish(new PingMessage(pingId));

            ConsumeContext <Fault <PingMessage> > handled = await handler;

            Assert.That(handled.Headers.Get <int>(MessageHeaders.FaultRetryCount), Is.GreaterThan(0));

            await InactivityTask.ContinueWith(task =>
            {
            });

            Assert.LessOrEqual(_attempts[pingId], _limit + 1);
        }