Masstransit - 请求的服务 'MassTransit.Scoping.ScopedConsumeContextProvider' 在收到互操作性消息后尚未注册
Masstransit - The requested service 'MassTransit.Scoping.ScopedConsumeContextProvider' has not been registered after receive interoperability message
我正在升级到最新的 Masstransit 版本,当我尝试使用文档中描述的最小消息发布原始消息时 json 会生成以下错误:
http://masstransit-project.com/architecture/interoperability.html
{
"message": {
"value": "Some Value",
"customerId": 27
},
"messageType": [
"urn:message:MassTransit.Tests:ValueMessage"
]
}
System.Runtime.Serialization.SerializationException: No deserializer was registered for the message content type: application/json. Supported content types include application/vnd.masstransit+json, application/vnd.masstransit+bson, application/vnd.masstransit+xml
**Adding the header Content_type application/vnd.masstransit+json and publishing again generates the follow error:**
Content-Type: application/vnd.masstransit+json
MT-Fault-ConsumerType: DocumentRouting.API.Consumers.DocumentRoutingConsumer
MT-Fault-ExceptionType: Autofac.Core.Registration.ComponentNotRegisteredException
MT-Fault-Message: The requested service 'MassTransit.Scoping.ScopedConsumeContextProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
MT-Fault-MessageType: EventBus.IntegrationEvents.IMessageReceivedIntegrationEvent
MT-Fault-StackTrace: at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at MassTransit.ExtensionsDependencyInjectionIntegration.ScopeProviders.InternalScopeExtensions.UpdateScope(IServiceScope scope, ConsumeContext context)
at MassTransit.ExtensionsDependencyInjectionIntegration.ScopeProviders.DependencyInjectionConsumerScopeProvider.MassTransit.Scoping.IConsumerScopeProvider.GetScope[TConsumer,T](ConsumeContext`1 context)
at MassTransit.Scoping.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)
at GreenPipes.Filters.TeeFilter`1.<>c__DisplayClass5_0.<<Send>g__SendAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at GreenPipes.Filters.OutputPipeFilter`2.SendToOutput(IPipe`1 next, TOutput pipeContext)
at GreenPipes.Filters.OutputPipeFilter`2.SendToOutput(IPipe`1 next, TOutput pipeContext)
at MassTransit.Pipeline.Filters.DeserializeFilter.Send(ReceiveContext context, IPipe`1 next)
at GreenPipes.Filters.RescueFilter`2.GreenPipes.IFilter<TContext>.Send(TContext context, IPipe`1 next)
环境:
ASP.NET 核心 3.1
使用 Autofac 容器替换的公共交通工具
Host.CreateDefaultBuilder(args).UseServiceProviderFactory(new AutofacServiceProviderFactory())
Masstransit initialization using Autofac Module:
protected override void Load(ContainerBuilder builder)
{
builder.AddMassTransit(x =>
{
x.AddConsumer<ConsumerName>();
x.UsingRabbitMq((context, config) =>
{
config.Host(new Uri(busSettings.RabbitMQHost), h =>
{
h.Username(busSettings.Username);
h.Password(busSettings.Password);
});
config.ReceiveEndpoint(busSettings.QueueName, ec =>
{
ec.Consumer<ConsumerName>(context, cc =>
{
你的问题似乎被打断了,但你应该使用:
config.ReceiveEndpoint(busSettings.QueueName, ec =>
{
ec.ConfigureConsumer<ConsumerName>(context, cc =>
{
添加剩余的配置代码后,可能还有其他 issues/solutions。
我正在升级到最新的 Masstransit 版本,当我尝试使用文档中描述的最小消息发布原始消息时 json 会生成以下错误: http://masstransit-project.com/architecture/interoperability.html
{
"message": {
"value": "Some Value",
"customerId": 27
},
"messageType": [
"urn:message:MassTransit.Tests:ValueMessage"
]
}
System.Runtime.Serialization.SerializationException: No deserializer was registered for the message content type: application/json. Supported content types include application/vnd.masstransit+json, application/vnd.masstransit+bson, application/vnd.masstransit+xml
**Adding the header Content_type application/vnd.masstransit+json and publishing again generates the follow error:**
Content-Type: application/vnd.masstransit+json
MT-Fault-ConsumerType: DocumentRouting.API.Consumers.DocumentRoutingConsumer
MT-Fault-ExceptionType: Autofac.Core.Registration.ComponentNotRegisteredException
MT-Fault-Message: The requested service 'MassTransit.Scoping.ScopedConsumeContextProvider' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
MT-Fault-MessageType: EventBus.IntegrationEvents.IMessageReceivedIntegrationEvent
MT-Fault-StackTrace: at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at MassTransit.ExtensionsDependencyInjectionIntegration.ScopeProviders.InternalScopeExtensions.UpdateScope(IServiceScope scope, ConsumeContext context)
at MassTransit.ExtensionsDependencyInjectionIntegration.ScopeProviders.DependencyInjectionConsumerScopeProvider.MassTransit.Scoping.IConsumerScopeProvider.GetScope[TConsumer,T](ConsumeContext`1 context)
at MassTransit.Scoping.ScopeConsumerFactory`1.Send[TMessage](ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.GreenPipes.IFilter<MassTransit.ConsumeContext<TMessage>>.Send(ConsumeContext`1 context, IPipe`1 next)
at GreenPipes.Filters.TeeFilter`1.<>c__DisplayClass5_0.<<Send>g__SendAsync|1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at GreenPipes.Filters.OutputPipeFilter`2.SendToOutput(IPipe`1 next, TOutput pipeContext)
at GreenPipes.Filters.OutputPipeFilter`2.SendToOutput(IPipe`1 next, TOutput pipeContext)
at MassTransit.Pipeline.Filters.DeserializeFilter.Send(ReceiveContext context, IPipe`1 next)
at GreenPipes.Filters.RescueFilter`2.GreenPipes.IFilter<TContext>.Send(TContext context, IPipe`1 next)
环境: ASP.NET 核心 3.1 使用 Autofac 容器替换的公共交通工具
Host.CreateDefaultBuilder(args).UseServiceProviderFactory(new AutofacServiceProviderFactory())
Masstransit initialization using Autofac Module:
protected override void Load(ContainerBuilder builder)
{
builder.AddMassTransit(x =>
{
x.AddConsumer<ConsumerName>();
x.UsingRabbitMq((context, config) =>
{
config.Host(new Uri(busSettings.RabbitMQHost), h =>
{
h.Username(busSettings.Username);
h.Password(busSettings.Password);
});
config.ReceiveEndpoint(busSettings.QueueName, ec =>
{
ec.Consumer<ConsumerName>(context, cc =>
{
你的问题似乎被打断了,但你应该使用:
config.ReceiveEndpoint(busSettings.QueueName, ec =>
{
ec.ConfigureConsumer<ConsumerName>(context, cc =>
{
添加剩余的配置代码后,可能还有其他 issues/solutions。