diff --git a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_enabled_with_no_support.cs b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_enabled_with_no_support.cs index ffb95d76ba..c2266bb2c3 100644 --- a/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_enabled_with_no_support.cs +++ b/src/NServiceBus.AcceptanceTests/Core/Recoverability/When_delayed_retries_enabled_with_no_support.cs @@ -1,6 +1,7 @@ -namespace NServiceBus.AcceptanceTests.Core.Recoverability; +namespace NServiceBus.AcceptanceTests.Core.Recoverability; using System; +using System.Threading.Tasks; using AcceptanceTesting; using EndpointTemplates; using NUnit.Framework; @@ -8,7 +9,7 @@ public class When_delayed_retries_enabled_with_no_support : NServiceBusAcceptanceTest { [Test] - public void Should_throw_on_startup() + public void Should_throw_when_explicitly_configured() { if (TestSuiteConstraints.Current.SupportsDelayedDelivery) { @@ -16,20 +17,40 @@ public void Should_throw_on_startup() } var exception = Assert.ThrowsAsync(async () => await Scenario.Define() - .WithEndpoint() + .WithEndpoint() .Done(c => c.EndpointsStarted) .Run()); - Assert.That(exception.ToString(), Does.Contain("Delayed retries are not supported when the transport does not support delayed delivery. Disable delayed retries using 'endpointConfiguration.Recoverability().Delayed(settings => settings.NumberOfRetries(0))'.")); + Assert.That(exception.ToString(), Does.Contain("Delayed retries are not supported when the transport does not support delayed delivery.")); } - public class StartedEndpoint : EndpointConfigurationBuilder + [Test] + public async Task Should_start_successfully_with_default_delayed_retries() { - public StartedEndpoint() => + if (TestSuiteConstraints.Current.SupportsDelayedDelivery) + { + Assert.Ignore("Ignoring this test because it requires the transport to not support delayed delivery."); + } + + await Scenario.Define() + .WithEndpoint() + .Done(c => c.EndpointsStarted) + .Run(); + } + + public class EndpointWithExplicitDelayedRetries : EndpointConfigurationBuilder + { + public EndpointWithExplicitDelayedRetries() => EndpointSetup((config, context) => { var recoverability = config.Recoverability(); recoverability.Delayed(i => i.NumberOfRetries(1)); }); } -} \ No newline at end of file + + public class EndpointWithDefaultDelayedRetries : EndpointConfigurationBuilder + { + public EndpointWithDefaultDelayedRetries() => + EndpointSetup(); + } +} diff --git a/src/NServiceBus.Core/Recoverability/RecoverabilityComponent.cs b/src/NServiceBus.Core/Recoverability/RecoverabilityComponent.cs index a3be93fa09..3739f205f2 100644 --- a/src/NServiceBus.Core/Recoverability/RecoverabilityComponent.cs +++ b/src/NServiceBus.Core/Recoverability/RecoverabilityComponent.cs @@ -181,7 +181,13 @@ static DelayedConfig CreateDelayedRetryConfig(bool transactionsOn, TransportDefi { if (!transportDefinition.SupportsDelayedDelivery) { - throw new Exception("Delayed retries are not supported when the transport does not support delayed delivery. Disable delayed retries using 'endpointConfiguration.Recoverability().Delayed(settings => settings.NumberOfRetries(0))'."); + if (settings.HasExplicitValue(NumberOfDelayedRetries)) + { + throw new Exception("Delayed retries are not supported when the transport does not support delayed delivery. Disable delayed retries using 'endpointConfiguration.Recoverability().Delayed(settings => settings.NumberOfRetries(0))'."); + } + + Logger.Info("Delayed retries have been disabled because the transport does not support delayed delivery."); + numberOfRetries = 0; } if (!transactionsOn)