Skip to content

Commit 2cac4f9

Browse files
committed
Messaging
1 parent bb893e4 commit 2cac4f9

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/Monolith/ClassifiedAds.Background/appsettings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
},
6363
"Consumers": {
6464
"WebhookConsumer": {
65-
//"Property_MaxRetryCount": 5,
66-
//"Property_DeadLetterEnabled": true,
65+
"MaxRetryCount": 5,
66+
"RetryIntervals": "10, 30, 50, 80, 130, 210, 340",
67+
"DeadLetterEnabled": true,
6768
"FileCreatedEvent": "webhook_classifiedadds_file_created",
6869
"FileUpdatedEvent": "webhook_classifiedadds_file_updated",
6970
"FileDeletedEvent": "webhook_classifiedadds_file_deleted",

src/Monolith/ClassifiedAds.Infrastructure/Messaging/MessagingCollectionExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public static IServiceCollection AddRabbitMQReceiver<TConsumer, T>(this IService
8181
AutomaticCreateEnabled = true,
8282
MessageEncryptionKey = options.MessageEncryptionKey,
8383
MaxRetryCount = options.GetMaxRetryCount(typeof(TConsumer).Name),
84+
RetryIntervals = options.GetRetryIntervals(typeof(TConsumer).Name),
8485
DeadLetterEnabled = options.GetDeadLetterEnabled(typeof(TConsumer).Name)
8586
};
8687

src/Monolith/ClassifiedAds.Infrastructure/Messaging/RabbitMQ/RabbitMQOptions.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
24

35
namespace ClassifiedAds.Infrastructure.Messaging.RabbitMQ;
46

@@ -35,11 +37,23 @@ public string TryGetProperty(string consumerName, string propertyName)
3537

3638
public int GetMaxRetryCount(string consumerName)
3739
{
38-
return int.TryParse(TryGetProperty(consumerName, "Property_MaxRetryCount"), out var maxRetryCount) ? maxRetryCount : 0;
40+
return int.TryParse(TryGetProperty(consumerName, "MaxRetryCount"), out var maxRetryCount) ? maxRetryCount : 0;
3941
}
4042

4143
public bool GetDeadLetterEnabled(string consumerName)
4244
{
43-
return bool.TryParse(TryGetProperty(consumerName, "Property_DeadLetterEnabled"), out var deadLetterEnabled) ? deadLetterEnabled : false;
45+
return bool.TryParse(TryGetProperty(consumerName, "DeadLetterEnabled"), out var deadLetterEnabled) ? deadLetterEnabled : false;
46+
}
47+
48+
public int[] GetRetryIntervals(string consumerName)
49+
{
50+
var s = TryGetProperty(consumerName, "RetryIntervals");
51+
52+
if (string.IsNullOrWhiteSpace(s))
53+
{
54+
return [];
55+
}
56+
57+
return [.. s.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)];
4458
}
4559
}

0 commit comments

Comments
 (0)