masstransit 集成hangfire
continuous-integration/drone/push Build is passing

This commit is contained in:
hang
2024-10-10 23:58:12 +08:00
parent a700658132
commit 1e99374de0
3 changed files with 42 additions and 0 deletions
+20
View File
@@ -35,6 +35,7 @@ using IRaCIS.Core.Application.MassTransit.Command;
using IRaCIS.Core.Application.MassTransit.Consumer;
using DocumentFormat.OpenXml.InkML;
using IRaCIS.Core.Domain;
using static IRaCIS.Core.Application.Service.TestService;
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
@@ -163,14 +164,33 @@ builder.Services.AddMassTransit(cfg =>
cfg.AddConsumer<AddSubjectTriggerConsumer>(); // 替换为你的消费者类
cfg.AddConsumer<AddSubjectTriggerConsumer2>();
cfg.AddConsumer<MasstransitHangfireTestConsumer>();
cfg.AddPublishMessageScheduler();
//cfg.AddHangfireConsumers();
// 使用 InMemory 作为消息传递机制
cfg.UsingInMemory((context, cfg) =>
{
//https://github.com/MassTransit/Sample-Hangfire/blob/master/src/Sample.Hangfire.Console/Program.cs
cfg.UsePublishMessageScheduler();
//使用 Hangfire 进行消息调度
cfg.UseHangfireScheduler();
// 这里可以进行额外的配置
cfg.ConfigureEndpoints(context); // 自动配置所有消费者的端点
});
});
//builder.Services.AddOptions<MassTransitHostOptions>().Configure(options =>
//{
// options.WaitUntilStarted = true;
//});
#endregion