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))
ConnectHandle IInstanceMessageConnector <TConsumer> .ConnectInstance(IConsumePipeConnector pipeConnector, TConsumer instance, IConsumerSpecification <TConsumer> specification) { if (pipeConnector == null) { throw new ArgumentNullException(nameof(pipeConnector)); } if (instance == null) { throw new ArgumentNullException(nameof(instance)); } if (specification == null) { throw new ArgumentNullException(nameof(specification)); } IConsumerMessageSpecification <TConsumer, TMessage> messageSpecification = specification.GetMessageSpecification <TMessage>(); IPipe <ConsumerConsumeContext <TConsumer, TMessage> > consumerPipe = messageSpecification.Build(_consumeFilter); IPipe <ConsumeContext <TMessage> > messagePipe = messageSpecification.BuildMessagePipe(x => { x.UseFilter(new InstanceMessageFilter <TConsumer, TMessage>(instance, consumerPipe)); }); return(pipeConnector.ConnectConsumePipe(messagePipe)); }
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); var factory = new BatchConsumerFactory <TConsumer, TMessage>(consumerFactory, messageLimit, concurrencyLimit, timeLimit, batchConsumerPipe); IConsumerSpecification <IConsumer <TMessage> > messageConsumerSpecification = ConsumerConnectorCache <IConsumer <TMessage> > .Connector.CreateConsumerSpecification <IConsumer <TMessage> >(); IConsumerMessageSpecification <IConsumer <TMessage>, TMessage> messageSpecification = messageConsumerSpecification.GetMessageSpecification <TMessage>(); IPipe <ConsumerConsumeContext <IConsumer <TMessage>, TMessage> > consumerPipe = messageSpecification.Build(new MethodConsumerMessageFilter <IConsumer <TMessage>, TMessage>()); IPipe <ConsumeContext <TMessage> > messagePipe = messageSpecification.BuildMessagePipe(x => { x.UseFilter(new ConsumerMessageFilter <IConsumer <TMessage>, TMessage>(factory, consumerPipe)); }); var handle = consumePipe.ConnectConsumePipe(messagePipe); return(new BatchConnectHandle(handle, factory)); }
public ConnectHandle ConnectConsumer(IConsumePipeConnector consumePipe, IConsumerFactory <TConsumer> consumerFactory, IConsumerSpecification <TConsumer> specification) { IConsumerMessageSpecification <TConsumer, TMessage> messageSpecification = specification.GetMessageSpecification <TMessage>(); IPipe <ConsumerConsumeContext <TConsumer, TMessage> > consumerPipe = messageSpecification.Build(_consumeFilter); IPipe <ConsumeContext <TMessage> > messagePipe = messageSpecification.BuildMessagePipe(x => { x.UseFilter(new ConsumerMessageFilter <TConsumer, TMessage>(consumerFactory, consumerPipe)); }); return(consumePipe.ConnectConsumePipe(messagePipe)); }
static IPipe <ConsumeContext <TJob> > CreateJobPipe(IConsumerFactory <TConsumer> consumerFactory, IConsumerSpecification <TConsumer> specification) { IConsumerMessageSpecification <TConsumer, TJob> messageSpecification = specification.GetMessageSpecification <TJob>(); var options = specification.Options <JobOptions <TJob> >(); var jobFilter = new JobConsumerMessageFilter <TConsumer, TJob>(options.RetryPolicy); IPipe <ConsumerConsumeContext <TConsumer, TJob> > consumerPipe = messageSpecification.Build(jobFilter); IPipe <ConsumeContext <TJob> > messagePipe = messageSpecification.BuildMessagePipe(x => { x.UseFilter(new ConsumerMessageFilter <TConsumer, TJob>(consumerFactory, consumerPipe)); }); return(messagePipe); }