Clinical Sync Batch Engine: first commit
This commit is contained in:
+18
-2
@@ -9,15 +9,18 @@ public sealed class NotificationPublisherService : BackgroundService
|
||||
private readonly IOptions<RabbitMqOptions> _rabbitOpts;
|
||||
private readonly KafkaOptions _kafkaOptions;
|
||||
private readonly ILogger<NotificationPublisherService> _logger;
|
||||
private readonly ClinicalSyncOptions _syncOptions;
|
||||
|
||||
public NotificationPublisherService(
|
||||
IOptions<RabbitMqOptions> rabbitOpts,
|
||||
IOptions<KafkaOptions> kafkaOptions,
|
||||
ILogger<NotificationPublisherService> logger)
|
||||
ILogger<NotificationPublisherService> logger,
|
||||
IOptions<ClinicalSyncOptions> syncOptions)
|
||||
{
|
||||
_rabbitOpts = rabbitOpts;
|
||||
_kafkaOptions = kafkaOptions.Value;
|
||||
_logger = logger;
|
||||
_syncOptions = syncOptions.Value;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
@@ -109,6 +112,19 @@ public sealed class NotificationPublisherService : BackgroundService
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var alertId = doc.RootElement.GetProperty("alertId").GetString();
|
||||
|
||||
// Skip paging for gateway-synced alerts when configured
|
||||
if (_syncOptions.SuppressPagingForSyncedAlerts
|
||||
&& doc.RootElement.TryGetProperty("syncedFromGateway", out var synced)
|
||||
&& synced.GetBoolean())
|
||||
{
|
||||
_logger.LogInformation(
|
||||
"Skipping central paging for gateway-synced alert {AlertId} — ward already paged locally",
|
||||
alertId);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var body = Encoding.UTF8.GetBytes(payload);
|
||||
chan.BasicPublish(
|
||||
exchange: RabbitMqTopologyProvisioner.Exchange,
|
||||
@@ -116,7 +132,7 @@ public sealed class NotificationPublisherService : BackgroundService
|
||||
basicProperties: props,
|
||||
body: body);
|
||||
|
||||
var alertId = doc.RootElement.GetProperty("alertId").GetString();
|
||||
|
||||
_logger.LogInformation("Published paging job to alerts.paging.queue for alert {AlertId}", alertId);
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
Reference in New Issue
Block a user