コード例 #1
0
        public ConnectHandle ConnectConsumer(IConsumePipeConnector consumePipe, IConsumerFactory <TConsumer> consumerFactory,
                                             IConsumerSpecification <TConsumer> specification)
        {
            var options = specification.Options <BatchOptions>();

            var messageLimit     = options.MessageLimit;
            var timeLimit        = options.TimeLimit;
            var concurrencyLimit = options.ConcurrencyLimit;

            IConsumerMessageSpecification <TConsumer, Batch <TMessage> > batchMessageSpecification = specification.GetMessageSpecification <Batch <TMessage> >();

            var consumeFilter = new MethodConsumerMessageFilter <TConsumer, Batch <TMessage> >();

            IPipe <ConsumerConsumeContext <TConsumer, Batch <TMessage> > > batchConsumerPipe = batchMessageSpecification.Build(consumeFilter);

            IPipe <ConsumeContext <Batch <TMessage> > > batchMessagePipe = batchMessageSpecification.BuildMessagePipe(x =>
            {
                x.UseFilter(new ConsumerMessageFilter <TConsumer, Batch <TMessage> >(consumerFactory, batchConsumerPipe));
            });

            IBatchCollector <TMessage> collector = null;

            if (options.GroupKeyProvider == null)
            {
                collector = new BatchCollector <TMessage>(messageLimit, timeLimit, concurrencyLimit, batchMessagePipe);
            }
            else
            {
                if (options.GroupKeyProvider.GetType().ClosesType(typeof(IGroupKeyProvider <,>), out Type[] types))
コード例 #2
0
        public BatchConsumerFactory(int messageLimit, TimeSpan timeLimit, IBatchCollector <TMessage> collector)
        {
            _messageLimit = messageLimit;
            _timeLimit    = timeLimit;

            _collector = collector;
        }