From f4863cc28d670655df15c1d7f31f0b97d23fc3c0 Mon Sep 17 00:00:00 2001 From: tba76 Date: Wed, 6 Sep 2023 13:08:48 +0200 Subject: [PATCH] Push to topic after fail --- .../Kafka/Consumers/EmailStatusConsumer.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Altinn.Notifications.Integrations/Kafka/Consumers/EmailStatusConsumer.cs b/src/Altinn.Notifications.Integrations/Kafka/Consumers/EmailStatusConsumer.cs index f019223d..a33cd2a4 100644 --- a/src/Altinn.Notifications.Integrations/Kafka/Consumers/EmailStatusConsumer.cs +++ b/src/Altinn.Notifications.Integrations/Kafka/Consumers/EmailStatusConsumer.cs @@ -1,4 +1,5 @@ -using Altinn.Notifications.Core.Models.Notification; +using Altinn.Notifications.Core.Integrations.Interfaces; +using Altinn.Notifications.Core.Models.Notification; using Altinn.Notifications.Core.Services.Interfaces; using Altinn.Notifications.Integrations.Configuration; @@ -13,14 +14,22 @@ namespace Altinn.Notifications.Integrations.Kafka.Consumers; public class EmailStatusConsumer : KafkaConsumerBase { private readonly IEmailNotificationService _emailNotificationsService; + private readonly IKafkaProducer _producer; + private readonly string _topicName; /// /// Initializes a new instance of the class. /// - public EmailStatusConsumer(IEmailNotificationService emailNotificationsService, IOptions settings, ILogger logger) + public EmailStatusConsumer( + IEmailNotificationService emailNotificationsService, + IKafkaProducer producer, + IOptions settings, + ILogger logger) : base(settings, logger, settings.Value.EmailStatusUpdatedTopicName) { _emailNotificationsService = emailNotificationsService; + _producer = producer; + _topicName = settings.Value.EmailStatusUpdatedTopicName; } /// @@ -43,7 +52,6 @@ private async Task ProcessOrder(string message) private async Task RetryOrder(string message) { - // Retry logic - back to kafka? - await Task.CompletedTask; + await _producer.ProduceAsync(_topicName, message!); } } \ No newline at end of file