简体   繁体   中英

MassTransit.ConfigurationException: The job service must be configured prior to configuring a job consumer, using either ConfigureJobServiceEndpoints

Need some help to incorporate JobService into my current MassTransit. My current project work great with MassTransit Consumer, since I have some long run process, and I don't want to hold up the RabbitMq, so I tried to adopt JobService. I follow the JobService example, but run into the error:

MassTransit.ConfigurationException: The job service must be configured prior to configuring a job consumer, using either ConfigureJobServiceEndpoints or ConfigureJobService at MassTransit.Configuration.JobConsumerMessageConnector 2.ConnectConsumer(IConsumePipeConnector consumePipe, IConsumerFactory 1 consumerFactory, IConsumerSpecification`1 specification) in /_/src/MassTransit/Consumers/Configuration/JobConsumerMessageConnector.cs

This is my setup:

services.AddMassTransit(busConfig =>
                {
                    if (isReceiver)
                    {
                        busConfig.AddConsumer<JobItemPayloadConsumer>(cfg =>
                        {
                            cfg.Options<JobOptions<JobItemPayLoad>>(options => options
                                .SetConcurrentJobLimit(10));
                        });
                    }
 
                    busConfig.AddSagaRepository<JobSaga>()
                       .EntityFrameworkRepository(r =>
                       {
                           r.ExistingDbContext<JobServiceSagaDbContext>();
                           r.UseSqlServer();
                       });
 
                    busConfig.AddSagaRepository<JobTypeSaga>()
                                .EntityFrameworkRepository(r =>
                                {
                                    r.ExistingDbContext<JobServiceSagaDbContext>();
                                    r.UseSqlServer();
                                });
 
                    busConfig.AddSagaRepository<JobAttemptSaga>()
                                .EntityFrameworkRepository(r =>
                                {
                                    r.ExistingDbContext<JobServiceSagaDbContext>();
                                    r.UseSqlServer();
                                });
 
                    busConfig.SetKebabCaseEndpointNameFormatter();
 
                    busConfig.UsingRabbitMq((context, cfg) =>
                    {
                        var host = GetServiceBusHostingUri(config, env, busConfig);
 
                        InitializeMassTransitBus(config, busConfig, context, cfg, host);
 
                        cfg.ServiceInstance(instance =>
                        {
                            instance.ConfigureJobService();
                            instance.ConfigureJobServiceEndpoints();
 
                            // configure the job consumer on the job service endpoints
                            instance.ConfigureEndpoints(context);
                        });
 
                        busConfig
                            .ConfigureSagas(config, host)
                            .ConfigureEndpoints(cfg, config, host)
                        ;
 
                        cfg.ConfigureEndpoints(context);
 
                        if (isReceiver)
                        {
                            busConfig
                                .ConfigureReceivers(cfg, config, context);
                        }
                    });
                });

Thank you

never mind, I figured the issue. I need to register the ServiceInstance before the ConfigureEndpoints(context).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM