forked from gongxuegit/tiku-backend.net
feat(security): complete capability messaging workflows
This commit is contained in:
@@ -37,6 +37,9 @@ builder.Services.AddOptions<MessagingOptions>()
|
||||
!string.IsNullOrWhiteSpace(options.Username) &&
|
||||
!string.IsNullOrWhiteSpace(options.Password)),
|
||||
"Production RabbitMQ requires a valid Host, Username and Password.")
|
||||
.Validate(
|
||||
options => options.OutboxBacklogAlertCount > 0 && options.OutboxOldestMessageAlertSeconds > 0,
|
||||
"RabbitMQ outbox alert thresholds must be positive.")
|
||||
.ValidateOnStart();
|
||||
if (messaging.IsConfigured)
|
||||
{
|
||||
|
||||
@@ -2,12 +2,14 @@ using Microsoft.Extensions.Options;
|
||||
using Tiku.Application.Jobs;
|
||||
using Tiku.Application.Security;
|
||||
using Tiku.Application.Tenancy;
|
||||
using Tiku.Infrastructure.Messaging;
|
||||
|
||||
namespace Tiku.Worker;
|
||||
|
||||
public class Worker(
|
||||
IServiceScopeFactory scopeFactory,
|
||||
IOptions<DomainLifecycleOptions> options,
|
||||
MessagingOptions messagingOptions,
|
||||
ILogger<Worker> logger) : BackgroundService
|
||||
{
|
||||
private readonly string workerId = $"{Environment.MachineName}:{Guid.NewGuid():N}";
|
||||
@@ -60,6 +62,10 @@ public class Worker(
|
||||
.InitializeSystem(null, "Background job lease worker");
|
||||
return await scope.ServiceProvider
|
||||
.GetRequiredService<IBackgroundJobService>()
|
||||
.ProcessPendingAsync(workerId, 20, stoppingToken);
|
||||
.ProcessPendingAsync(
|
||||
workerId,
|
||||
20,
|
||||
includeImmediateJobs: !messagingOptions.IsConfigured,
|
||||
cancellationToken: stoppingToken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
"Host": "",
|
||||
"VirtualHost": "/",
|
||||
"Username": "",
|
||||
"Password": ""
|
||||
"Password": "",
|
||||
"OutboxBacklogAlertCount": 1000,
|
||||
"OutboxOldestMessageAlertSeconds": 300
|
||||
},
|
||||
"TenantDomains": {
|
||||
"Enabled": true,
|
||||
|
||||
Reference in New Issue
Block a user