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.JobConsumerMessageConnector2.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).