IRC_NewDev
parent
0ac17ac27f
commit
3ff092fbda
|
@ -0,0 +1,30 @@
|
|||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.API.HostService
|
||||
{
|
||||
public class RecurringJobConfigurationService :
|
||||
BackgroundService
|
||||
{
|
||||
readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public RecurringJobConfigurationService(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
await using var scope = _scopeFactory.CreateAsyncScope();
|
||||
|
||||
var endpoint = scope.ServiceProvider.GetRequiredService<IPublishEndpoint>();
|
||||
|
||||
await endpoint.AddOrUpdateRecurringJob(nameof(MasstransitTestConsumer), new MasstransiTestCommand(), x => x.Every(minutes: 1),
|
||||
stoppingToken);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||
using IRaCIS.Core.API.HostService;
|
||||
using IRaCIS.Core.Application.MassTransit.Consumer;
|
||||
using IRaCIS.Core.Domain.BaseModel;
|
||||
using IRaCIS.Core.Infra.EFCore;
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
|
@ -49,8 +52,67 @@ namespace IRaCIS.Core.API
|
|||
|
||||
|
||||
});
|
||||
|
||||
#region rabitmq obsolute
|
||||
|
||||
//cfg.UsingRabbitMq((context, cfg) =>
|
||||
//{
|
||||
// cfg.UsePublishMessageScheduler();
|
||||
|
||||
// cfg.Host(
|
||||
// host: "106.14.89.110",
|
||||
// port: 5672,
|
||||
// virtualHost: "/",
|
||||
// configure: hostConfig =>
|
||||
// {
|
||||
// hostConfig.Username("rabbitmq");
|
||||
// hostConfig.Password("rabbitmq");
|
||||
// });
|
||||
|
||||
// cfg.ConfigureEndpoints(context);
|
||||
//});
|
||||
#endregion
|
||||
|
||||
#region Outbox obsolute
|
||||
|
||||
//cfg.AddConfigureEndpointsCallback((context, name, cfg) =>
|
||||
//{
|
||||
// cfg.UseEntityFrameworkOutbox<IRaCISDBContext>(context);
|
||||
|
||||
// //cfg.UseDelayedRedelivery(r => r.Intervals(TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(15), TimeSpan.FromMinutes(30)));
|
||||
|
||||
// //// 全局重试策略:重试 3 次,每次延迟 5 秒
|
||||
// //cfg.UseMessageRetry(retryConfig =>
|
||||
// //{
|
||||
// // retryConfig.Interval(3, TimeSpan.FromSeconds(10));
|
||||
// //});
|
||||
//});
|
||||
|
||||
//cfg.AddEntityFrameworkOutbox<IRaCISDBContext>(o =>
|
||||
//{
|
||||
// o.UseSqlServer();
|
||||
// o.UseBusOutbox();
|
||||
//});
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
//services.AddOptions<MassTransitHostOptions>()
|
||||
// .Configure(options =>
|
||||
// {
|
||||
// options.WaitUntilStarted = true;
|
||||
// options.StartTimeout = TimeSpan.FromMinutes(1);
|
||||
// options.StopTimeout = TimeSpan.FromMinutes(1);
|
||||
// });
|
||||
|
||||
//services.AddOptions<HostOptions>()
|
||||
// .Configure(options => options.ShutdownTimeout = TimeSpan.FromMinutes(1));
|
||||
|
||||
//services.AddHostedService<RecurringJobConfigurationService>();
|
||||
#endregion
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue