コード例 #1
0
        private async Task TestMessagesAreSentCommon()
        {
            _produceRouter.Route("test1p", new Message(), Partitions.Any, DateTime.UtcNow.AddMinutes(5));
            _produceRouter.Route("test1p", new Message(), Partitions.Any, DateTime.UtcNow.AddMinutes(5));
            _produceRouter.Route("test2p", new Message(), Partitions.Any, DateTime.UtcNow.AddMinutes(5));
            _produceRouter.Route("test2p", new Message(), Partitions.Any, DateTime.UtcNow.AddMinutes(5));
            _produceRouter.Route("testallp", new Message(), Partitions.Any, DateTime.UtcNow.AddMinutes(5));
            _produceRouter.Route("testallp", new Message(), Partitions.Any, DateTime.UtcNow.AddMinutes(5));

            await _produceRouter.Stop();

            Assert.AreEqual(2, _messagesSentByTopic["test1p"]);
            Assert.AreEqual(2, _messagesSentByTopic["test2p"]);
            Assert.AreEqual(2, _messagesSentByTopic["testallp"]);

            CheckCounters(expectedMessagesEnqueued: 6, expectedMessagesReEnqueued: 0, expectedMessagesRouted: 6, expectedMessagesExpired: 0, expectedRoutingTableRequired: 1);
        }
コード例 #2
0
ファイル: Cluster.cs プロジェクト: sdanzan/kafka-sharp
        public async Task Stop()
        {
            if (!_started)
            {
                return;
            }
            _timeoutScheduler.Dispose();
            _refreshMetadataTimer.Dispose();
            await ConsumeRouter.Stop();

            await ProduceRouter.Stop();

            _agent.Complete();
            await _agent.Completion;
            await Task.WhenAll(_nodes.Keys.Select(n => n.Stop()));

            _started = false;
        }