public static void ConfigureTurnoutEndpoints <T>(this IReceiveEndpointConfigurator configurator, IBusFactoryConfigurator busFactoryConfigurator, IReceiveEndpointConfigurator turnoutEndpointConfigurator, IReceiveEndpointConfigurator expiredEndpointConfigurator, Action <ITurnoutServiceConfigurator <T> > configure) where T : class { configurator.AddDependency(turnoutEndpointConfigurator); turnoutEndpointConfigurator.AddDependency(expiredEndpointConfigurator); var specification = new TurnoutServiceSpecification <T>(configurator); configure(specification); specification.ManagementAddress = turnoutEndpointConfigurator.InputAddress; busFactoryConfigurator.AddBusFactorySpecification(specification); var partitioner = busFactoryConfigurator.CreatePartitioner(specification.PartitionCount); expiredEndpointConfigurator.Consumer(() => new JobCustodian <T>(specification.JobRegistry), x => { x.Message <SuperviseJob <T> >(m => m.UsePartitioner(partitioner, p => p.Message.JobId)); }); turnoutEndpointConfigurator.Consumer(() => new JobSupervisor <T>(specification.Service, specification.JobRegistry), x => { x.Message <CancelJob>(m => m.UsePartitioner(partitioner, p => p.Message.JobId)); x.Message <SuperviseJob <T> >(m => m.UsePartitioner(partitioner, p => p.Message.JobId)); }); IJobFactory <T> jobFactory = specification.JobFactory; configurator.Consumer(() => new JobProducer <T>(specification.Service, jobFactory)); busFactoryConfigurator.BusObserver(() => new JobServiceBusObserver(specification.Service)); }