rabbitmq MassTransit.PayloadNotFoundException

9avjhtql  于 2023-10-20  发布在  RabbitMQ
关注(0)|答案(1)|浏览(193)

当我尝试消费一条消息时,我在rabbitmq管理中得到这个错误:

MT-Fault-ExceptionType: MassTransit.PayloadNotFoundException
MT-Fault-Message:   The payload was not found: MassTransit.MessageSchedulerContext
MT-Fault-StackTrace:    at MassTransit.PipeExtensions.GetPayload[TPayload](PipeContext context) in /_/src/MassTransit.Abstractions/Middleware/PipeExtensions.cs:line 55
at MassTransit.Context.ScheduleMessageRedeliveryContext`1.ScheduleRedelivery(TimeSpan delay, Action`2 callback) in /_/src/MassTransit/Contexts/Context/ScheduleMessageRedeliveryContext.cs:line 28
at MassTransit.Middleware.RedeliveryRetryFilter`2.Send(TContext context, IPipe`1 next) in /_/src/MassTransit/Middleware/RedeliveryRetryFilter.cs:line 101

这里是配置:

private static void AddMessagingConfiguration(IServiceCollection services, WebApplicationBuilder builder)
    {
        services.AddMassTransit(busConfigurator =>
        {
            busConfigurator.AddConsumer<GtsDocumentConsumer>();
            busConfigurator.AddEntityFrameworkOutbox<CompanyGoodsDbContext>(outboxConfigurator =>
            {
                outboxConfigurator.UseSqlServer();
                outboxConfigurator.UseBusOutbox();
                outboxConfigurator.QueryMessageLimit = 10;
                outboxConfigurator.QueryDelay = TimeSpan.FromSeconds(1);
                outboxConfigurator.QueryTimeout = TimeSpan.FromSeconds(30);
            });

            busConfigurator.AddOptions<MassTransitHostOptions>()
                .Configure(options =>
                {
                    options.WaitUntilStarted = true;
                    //options.StartTimeout = TimeSpan.FromSeconds(1);
                    //options.StopTimeout = TimeSpan.FromSeconds(30);
                });
            

            busConfigurator.UsingRabbitMq((busContext, transportConfigurator) =>
            {
                transportConfigurator.Host(builder.Configuration["EventBusSettings:HostAddress"], "/", hostConfiguration =>
                {
                    hostConfiguration.Username(builder.Configuration["EventBusSettings:Username"]);
                    hostConfiguration.Password(builder.Configuration["EventBusSettings:Password"]);
                });

                transportConfigurator.AutoStart = true;
                transportConfigurator.UseMessageRetry(r => r.Immediate(5));
                transportConfigurator.UseScheduledRedelivery(r =>
                    r.Intervals(TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(30)));
                transportConfigurator.ConfigureEndpoints(busContext);
            });
        });
    }

当我们在两个应用程序之间的docker中本地测试所有内容时,此配置工作正常,但现在当两个应用程序都在服务器上运行时,我得到了此错误

euoag5mw

euoag5mw1#

UseScheduledRedelivery -> UseDelayedRedelivery
需要RabbitMQ上的delayed-exchnage插件。
此外,根据文档,订单很重要:
UseDelayedRedelivery然后UseMessageRetry

相关问题