| 1234567891011121314151617181920212223242526272829303132 |
- using Admin.NET.Plugin.AiDOP.DataPlatform.Executors;
- using Furion.Schedule;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- namespace Admin.NET.Plugin.AiDOP.Job;
- /// <summary>
- /// 出站 Outbox 推送作业:扫描 mdp_outbox 待推记录并调用 MdpApiPushExecutor。
- /// </summary>
- [JobDetail("job_mdp_outbox_push", Description = "MDP Outbox 出站推送", GroupName = "default", Concurrent = false)]
- [PeriodSeconds(60, TriggerId = "trigger_mdp_outbox_push", Description = "每 60 秒扫描 Outbox", RunOnStart = false)]
- public class MdpOutboxPushJob : IJob
- {
- private readonly IServiceScopeFactory _scopeFactory;
- private readonly ILogger _logger;
- public MdpOutboxPushJob(IServiceScopeFactory scopeFactory, ILoggerFactory loggerFactory)
- {
- _scopeFactory = scopeFactory;
- _logger = loggerFactory.CreateLogger(nameof(MdpOutboxPushJob));
- }
- public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
- {
- using var scope = _scopeFactory.CreateScope();
- var executor = scope.ServiceProvider.GetRequiredService<MdpApiPushExecutor>();
- var (success, failed, skipped) = await executor.PushPendingAsync(50, stoppingToken);
- if (success + failed + skipped > 0)
- _logger.LogInformation("[MdpOutboxPushJob] success={Success} failed={Failed} retrying={Skipped}", success, failed, skipped);
- }
- }
|