admin管理员组文章数量:1418594
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
Share Improve this question asked Jan 29 at 12:51 ZoZZoZ 3,5982 gold badges18 silver badges46 bronze badges 4 |1 Answer
Reset to default 0Ok. 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.
本文标签: net 80Client injection exception after upgrading MassTransit from 833 to 835Stack Overflow
版权声明:本文标题:.net 8.0 - Client injection exception after upgrading MassTransit from 8.3.3 to 8.3.5 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745297008a2652141.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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