public ConnectHandle ConnectConsumer(IConsumePipeConnector consumePipe, IConsumerFactory <TConsumer> consumerFactory, IConsumerSpecification <TConsumer> specification) { var jobServiceOptions = specification.Options <JobServiceOptions>(); if (jobServiceOptions.JobService == null) { throw new ConfigurationException( "The job service must be configured prior to configuring a job consumer, using either ConfigureJobServiceEndpoints or ConfigureJobService"); } var options = specification.Options <JobOptions <TJob> >(); IConsumerMessageSpecification <TConsumer, TJob> messageSpecification = specification.GetMessageSpecification <TJob>(); var turnoutSpecification = messageSpecification as JobConsumerMessageSpecification <TConsumer, TJob>; if (turnoutSpecification == null) { throw new ArgumentException("The consumer specification did not match the message specification type"); } var submitJobHandle = ConnectSubmitJobConsumer(consumePipe, turnoutSpecification.SubmitJobSpecification, options); var startJobHandle = ConnectStartJobConsumer(consumePipe, turnoutSpecification.StartJobSpecification, options, jobServiceOptions.JobService, CreateJobPipe(consumerFactory, specification)); var cancelJobHandle = ConnectSuperviseJobConsumer(consumePipe, turnoutSpecification.SuperviseJobSpecification, jobServiceOptions.JobService); return(new MultipleConnectHandle(submitJobHandle, startJobHandle, cancelJobHandle)); }
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))
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) { var jobServiceOptions = specification.Options <JobServiceOptions>(); var jobService = jobServiceOptions.JobService; if (jobService == null || jobServiceOptions.InstanceEndpointConfigurator == null) { throw new ConfigurationException( "The job service must be configured prior to configuring a job consumer, using either ConfigureJobServiceEndpoints or ConfigureJobService"); } var options = specification.Options <JobOptions <TJob> >(); var jobTypeId = jobService.GetJobTypeId <TJob>(); IConsumerMessageSpecification <TConsumer, TJob> messageSpecification = specification.GetMessageSpecification <TJob>(); var jobSpecification = messageSpecification as JobConsumerMessageSpecification <TConsumer, TJob>; if (jobSpecification == null) { throw new ArgumentException("The consumer specification did not match the message specification type"); } var submitJobHandle = ConnectSubmitJobConsumer(consumePipe, jobSpecification.SubmitJobSpecification, options, jobTypeId); IPipe <ConsumeContext <TJob> > jobPipe = CreateJobPipe(consumerFactory, specification); var startJobHandle = ConnectStartJobConsumer(consumePipe, jobSpecification.StartJobSpecification, options, jobService, jobPipe); ConfigureStartJobConsumer(jobServiceOptions.InstanceEndpointConfigurator, options, jobService, jobPipe); var finalizeJobHandle = ConnectFinalizeJobConsumer(consumePipe, jobSpecification.FinalizeJobSpecification, options, jobService); var superviseJobHandle = ConnectSuperviseJobConsumer(consumePipe, jobSpecification.SuperviseJobSpecification, jobService); ConfigureSuperviseJobConsumer(jobServiceOptions.InstanceEndpointConfigurator, jobService); return(new MultipleConnectHandle(submitJobHandle, startJobHandle, finalizeJobHandle, superviseJobHandle)); }
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); }
public T Options <T>(Action <T> configure = null) where T : IOptions, new() { return(_specification.Options(configure)); }