Skip to content

Commit

Permalink
Validate the DelayedDeliveryPoisonQueue only after the fallbacks didn…
Browse files Browse the repository at this point in the history
…'t return anything
  • Loading branch information
danielmarbach committed Mar 12, 2024
1 parent eb737b5 commit 34aebbe
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/Transport/AzureStorageQueueTransport.cs
Expand Up @@ -143,8 +143,6 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
Guard.AgainstNull(nameof(receiversSettings), receiversSettings);
Guard.AgainstNull(nameof(sendingAddresses), sendingAddresses);

ValidateReceiversSettings(receiversSettings);

var localAccountInfo = new AccountInfo("", queueServiceClientProvider.Client, tableServiceClientProvider.Client);

var azureStorageAddressing = new AzureStorageAddressingSettings(QueueAddressGenerator,
Expand Down Expand Up @@ -231,6 +229,15 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
var nativeDelayedDeliveryErrorQueue = DelayedDelivery.DelayedDeliveryPoisonQueue
?? hostSettings.CoreSettings?.GetOrDefault<string>(ErrorQueueSettings.SettingsKey)
?? receiversSettings.Select(settings => settings.ErrorQueue).FirstOrDefault();

Check failure on line 232 in src/Transport/AzureStorageQueueTransport.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 232 in src/Transport/AzureStorageQueueTransport.cs

View workflow job for this annotation

GitHub Actions / Windows

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 232 in src/Transport/AzureStorageQueueTransport.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 232 in src/Transport/AzureStorageQueueTransport.cs

View workflow job for this annotation

GitHub Actions / Linux

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
var isSendOnly = receiversSettings.Length == 0;
if (isSendOnly && string.IsNullOrWhiteSpace(nativeDelayedDeliveryErrorQueue))
{
throw new Exception("Send only endpoints require a native delayed poison queue." +
" Configure a user defined poison queue for delayed deliveries by using the" +
$" {nameof(AzureStorageQueueTransport)}.{nameof(DelayedDelivery)}" +
$".{nameof(DelayedDelivery.DelayedDeliveryPoisonQueue)} property.");
}

nativeDelayedDeliveryProcessor = new NativeDelayedDeliveryProcessor(
dispatcher,
Expand Down Expand Up @@ -305,18 +312,6 @@ await queueCreator.CreateQueueIfNecessary(queuesToCreate, cancellationToken)
return infrastructure;
}

void ValidateReceiversSettings(ReceiveSettings[] receivers)
{
var isSendOnly = receivers.Length == 0;
if (SupportsDelayedDelivery && isSendOnly && string.IsNullOrWhiteSpace(DelayedDelivery.DelayedDeliveryPoisonQueue))
{
throw new Exception("Send only endpoints require a native delayed poison queue." +
" Configure a user defined poison queue for delayed deliveries by using the" +
$" {nameof(AzureStorageQueueTransport)}.{nameof(DelayedDelivery)}" +
$".{nameof(DelayedDelivery.DelayedDeliveryPoisonQueue)} property.");
}
}

static async Task<TableClient> EnsureNativeDelayedDeliveryTable(string endpointName, string delayedDeliveryTableName, TableServiceClient tableServiceClient, bool setupInfrastructure, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(delayedDeliveryTableName))
Expand Down

0 comments on commit 34aebbe

Please sign in to comment.