Skip to content

Commit

Permalink
Refactored bad naming of method
Browse files Browse the repository at this point in the history
  • Loading branch information
HansDahle committed Oct 17, 2023
1 parent e55eb7d commit 54bccd4
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,8 @@ public async Task SendMessageDelayedAsync(QueuePath queue, object message, int d

var jsonMessage = JsonSerializer.Serialize(message);

var entityPath = Resolve(queue);

if (string.IsNullOrEmpty(entityPath))
throw new InvalidOperationException($"Could not resolve the serivce bus entity path for queue '{queue}'");

var entityPath = ResolveQueuePath(queue);
var queueSender = client.CreateSender(entityPath);


var sbMessage = new ServiceBusMessage(jsonMessage) { ContentType = "application/json" };
if (delayInSeconds > 0)
Expand All @@ -62,14 +57,24 @@ public async Task SendMessageDelayedAsync(QueuePath queue, object message, int d
}
}

private string? Resolve(QueuePath queue)
/// <summary>
/// Queue path should be configured in config. The config key should be the enum value.
///
/// </summary>
/// <param name="queue"></param>
/// <returns></returns>
private string ResolveQueuePath(QueuePath queue)
{
var entityPath = configuration.GetValue<string>($"ServiceBus:Queues:{queue}", DefaultQueuePath(queue));
var entityPath = configuration.GetValue<string>($"ServiceBus:Queues:{queue}");


var entityPathOverride = configuration.GetValue<string>($"SERVICEBUS_QUEUES_{queue}");
if (!string.IsNullOrEmpty(entityPathOverride))
entityPath = entityPathOverride;

if (string.IsNullOrEmpty(entityPath))
entityPath = DefaultQueuePath(queue);

logger.LogInformation($"Using service bus queue: {entityPath}");

return entityPath;
Expand Down

0 comments on commit 54bccd4

Please sign in to comment.