{"record":{"id":"c2f5750b6f04a721","repo":"MassTransit/MassTransit","slug":"consumer-is-excluded-from-configureendpoints","errorCode":null,"errorMessage":"Consumer is excluded from ConfigureEndpoints","messagePattern":"Consumer is excluded from ConfigureEndpoints","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/MassTransit/DependencyInjection/DependencyInjection/Registration/Consumers/ConsumerRegistrationConfigurator.cs","lineNumber":23,"sourceCode":"\n\n    public class ConsumerRegistrationConfigurator<TConsumer> :\n        IConsumerRegistrationConfigurator<TConsumer>\n        where TConsumer : class, IConsumer\n    {\n        readonly IRegistrationConfigurator _configurator;\n        readonly IConsumerRegistration _registration;\n\n        public ConsumerRegistrationConfigurator(IRegistrationConfigurator configurator, IConsumerRegistration registration)\n        {\n            _configurator = configurator;\n            _registration = registration;\n        }\n\n        public void Endpoint(Action<IEndpointRegistrationConfigurator> configure)\n        {\n            if (!_registration.IncludeInConfigureEndpoints)\n                throw new ConfigurationException(\"Consumer is excluded from ConfigureEndpoints\");\n\n            var configurator = new EndpointRegistrationConfigurator<TConsumer>();\n\n            configure?.Invoke(configurator);\n\n            _configurator.AddEndpoint<ConsumerEndpointDefinition<TConsumer>, TConsumer>(_registration, configurator.Settings);\n        }\n\n        public void ExcludeFromConfigureEndpoints()\n        {\n            _registration.IncludeInConfigureEndpoints = false;\n        }\n    }\n}\n","sourceCodeStart":5,"sourceCodeEnd":38,"githubUrl":"https://github.com/MassTransit/MassTransit/blob/62ab339afa3bac2e9b3fe1769d0d35d7e44778e9/src/MassTransit/DependencyInjection/DependencyInjection/Registration/Consumers/ConsumerRegistrationConfigurator.cs#L5-L38","documentation":"A consumer was explicitly removed from automatic endpoint configuration (ExcludeFromConfigureEndpoints), so calling Endpoint() on its registration configurator is a contradiction: the consumer opted out of ConfigureEndpoints, and per-consumer endpoint customization is only meaningful for consumers included in it. MassTransit throws ConfigurationException to prevent a silently-ignored configuration call.","triggerScenarios":"Calling .Endpoint(cfg => ...) on the IConsumerRegistrationConfigurator after having called .ExcludeFromConfigureEndpoints() on the same consumer registration.","commonSituations":"Copy-pasting registration code where one consumer was excluded from ConfigureEndpoints but still has endpoint customization; refactoring endpoint configuration from automatic to manual without removing the Endpoint() call.","solutions":["Remove the ExcludeFromConfigureEndpoints() call if you want per-consumer Endpoint configuration.","Remove the Endpoint(...) call and configure the receive endpoint manually if the consumer must stay excluded.","Configure the endpoint inline when adding the consumer, e.g. via AddConsumer with the configure callback and an explicit endpoint definition."],"exampleFix":"// before\nx.AddConsumer<OrderConsumer>()\n    .ExcludeFromConfigureEndpoints()\n    .Endpoint(e => e.PrefetchCount = 10);\n\n// after\nx.AddConsumer<OrderConsumer>()\n    .Endpoint(e => e.PrefetchCount = 10);","handlingStrategy":"validation","validationCode":"if (consumerRegistration.ExcludeFromConfigureEndpoints)\n    throw new InvalidOperationException(\"Cannot call Endpoint() on a consumer excluded from ConfigureEndpoints.\");","typeGuard":null,"tryCatchPattern":"try { registration.Endpoint(cfg => cfg.PrefetchCount = 10); }\ncatch (ConfigurationException ex) { logger.LogWarning(ex.Message); }","preventionTips":["Choose one configuration style per consumer: ConfigureEndpoints + Endpoint(), or fully manual endpoints.","Search registrations for ExcludeFromConfigureEndpoints before adding Endpoint calls.","Centralize consumer registration conventions in one extension method."],"tags":["masstransit","configuration","endpoint","consumer"],"backgroundTag":"conflicting-config-options","analyzedSha":"62ab339afa3bac2e9b3fe1769d0d35d7e44778e9","analyzedAt":"2026-09-13T22:47:47.593Z","contentChangedAt":"2026-09-13T22:47:47.593Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}