I have upgraded MassTransit in my project from 8.3.3 to 8.3.5 without modifying any configuration, and I am getting following exception when trying to inject the IRequestClient<>
:
MassTransit.MassTransitException: Unable to resolve client factory or mediator for request client: <MyRequestTye>
at MassTransit.DependencyInjection.GenericRequestClient`1.GetRequestClient(IServiceProvider provider) in /_/src/MassTransit/DependencyInjection/DependencyInjection/GenericRequestClient.cs:line 137
at MassTransit.DependencyInjection.GenericRequestClient`1..ctor(IServiceProvider provider) in /_/src/MassTransit/DependencyInjection/DependencyInjection/GenericRequestClient.cs:line 18
As I upgraded several packages simultaneously, I reverted just this one back to 8.3.3, and it works as before.
this is my configuration code:
builder.Services.AddMassTransit<TBus>(x =>
{
var opts = builder.Configuration.GetRequiredSection(key).Get<RabbitMQOptions>() ?? throw new ConfigurationException($"Configuration key '{key}' of type '{nameof(RabbitMQOptions)}' missing!");
foreach (var consumer in consumers)
{
x.AddConsumer(consumer);
}
foreach (var request in requestTypes)
{
x.AddRequestClient(request);
}
x.UsingRabbitMq((context, cfg) =>
{
cfg.Host(opts.Host, opts.Port, bus, builder.Environment.ApplicationName, h =>
{
h.Username(opts.UserName);
h.Password(opts.Password);
h.Heartbeat(30);
});
cfg.ConfigureJsonSerializerOptions(options => options
.AddConvertersFrom(CustomJsonSerializationOptions.ContractOptions)
.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)
);
cfg.ConfigureEndpoints(context, new KebabCaseEndpointNameFormatter(bus, false));
});
});
I don't see anything in this post that should have this effect:
I have upgraded MassTransit in my project from 8.3.3 to 8.3.5 without modifying any configuration, and I am getting following exception when trying to inject the IRequestClient<>
:
MassTransit.MassTransitException: Unable to resolve client factory or mediator for request client: <MyRequestTye>
at MassTransit.DependencyInjection.GenericRequestClient`1.GetRequestClient(IServiceProvider provider) in /_/src/MassTransit/DependencyInjection/DependencyInjection/GenericRequestClient.cs:line 137
at MassTransit.DependencyInjection.GenericRequestClient`1..ctor(IServiceProvider provider) in /_/src/MassTransit/DependencyInjection/DependencyInjection/GenericRequestClient.cs:line 18
As I upgraded several packages simultaneously, I reverted just this one back to 8.3.3, and it works as before.
this is my configuration code:
builder.Services.AddMassTransit<TBus>(x =>
{
var opts = builder.Configuration.GetRequiredSection(key).Get<RabbitMQOptions>() ?? throw new ConfigurationException($"Configuration key '{key}' of type '{nameof(RabbitMQOptions)}' missing!");
foreach (var consumer in consumers)
{
x.AddConsumer(consumer);
}
foreach (var request in requestTypes)
{
x.AddRequestClient(request);
}
x.UsingRabbitMq((context, cfg) =>
{
cfg.Host(opts.Host, opts.Port, bus, builder.Environment.ApplicationName, h =>
{
h.Username(opts.UserName);
h.Password(opts.Password);
h.Heartbeat(30);
});
cfg.ConfigureJsonSerializerOptions(options => options
.AddConvertersFrom(CustomJsonSerializationOptions.ContractOptions)
.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)
);
cfg.ConfigureEndpoints(context, new KebabCaseEndpointNameFormatter(bus, false));
});
});
I don't see anything in this post that should have this effect: https://masstransit.io/support/upgrade#version-835
Ok. I finally figured it out. And it is strange. Was there an autodiscovery or something in version 3.3 that was removed afterwards? Actually, in that specific scenario, I fot to register the request that was declared in another library (I had some bootsrtapper for that not properly called there). The consumer was in yet project, not even referenced. Hence, there was literally no way MassTransit would know which classes are requests, except if there was some kind of convention to autoregister them.
Anyway, after explicit registration, it works with the latest version as well.
MyRequestTye
that it's trying to resolve a handler for, has this, or its dependencies changed in anyway? – David Osborne Commented Feb 4 at 8:39