我正在升级到最新的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 Core 3.1 Masstransit,带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 =>
{发布于 2020-11-28 01:02:16
你的问题似乎被打断了,但你应该使用:
config.ReceiveEndpoint(busSettings.QueueName, ec =>
{
ec.ConfigureConsumer<ConsumerName>(context, cc =>
{一旦添加了配置代码的其余部分,可能会出现其他问题/解决方案。
https://stackoverflow.com/questions/65040099
复制相似问题