示例#1
0
        public async Task TestWith100Messages()
        {
            var responses = MakeResponses(100);
            var dummySQS  = new FixedDataSqs(responses);

            int receivedCount = 0;

            async Task <bool> Handler(Message message)
            {
                await Task.Delay(50);

                Console.WriteLine($"Handled message {message.Body}");

                Interlocked.Increment(ref receivedCount);
                return(true);
            }

            var wrappedHandler = Handlers.Wrap(Handler, dummySQS, OnTiming, OnException);

            var listener = new SimpleListener(dummySQS,
                                              wrappedHandler,
                                              CancelAfterSeconds(5),
                                              new NullListenerLogger());

            await listener.Listen();

            Assert.Equal(100, receivedCount);
        }
示例#2
0
        public async Task RunForASecond()
        {
            var dummySqs = new FixedDataSqs(Enumerable.Empty <ReceiveMessageResponse>());

            var listener = new SimpleListener(
                dummySqs,
                Handler,
                CancelAfterSeconds(1),
                new NullListenerLogger());

            await listener.Listen();
        }
示例#3
0
        public async Task RunForFiveSeconds()
        {
            var dummySQS = new FixedDataSqs(Enumerable.Empty <ReceiveMessageResponse>());

            var handler = Handlers.Wrap(Handler, dummySQS, OnTiming, OnException);

            var listener = new SimpleListener(dummySQS,
                                              handler,
                                              CancelAfterSeconds(5),
                                              new NullListenerLogger());

            await listener.Listen();
        }