Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,35 +1,56 @@
namespace NServiceBus.AcceptanceTests.Core.Recoverability;
namespace NServiceBus.AcceptanceTests.Core.Recoverability;

using System;
using System.Threading.Tasks;
using AcceptanceTesting;
using EndpointTemplates;
using NUnit.Framework;

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)
{
Assert.Ignore("Ignoring this test because it requires the transport to not support delayed delivery.");
}

var exception = Assert.ThrowsAsync<Exception>(async () => await Scenario.Define<ScenarioContext>()
.WithEndpoint<StartedEndpoint>()
.WithEndpoint<EndpointWithExplicitDelayedRetries>()
.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<ScenarioContext>()
.WithEndpoint<EndpointWithDefaultDelayedRetries>()
.Done(c => c.EndpointsStarted)
.Run();
}

public class EndpointWithExplicitDelayedRetries : EndpointConfigurationBuilder
{
public EndpointWithExplicitDelayedRetries() =>
EndpointSetup<DefaultServer>((config, context) =>
{
var recoverability = config.Recoverability();
recoverability.Delayed(i => i.NumberOfRetries(1));
});
}
}

public class EndpointWithDefaultDelayedRetries : EndpointConfigurationBuilder
{
public EndpointWithDefaultDelayedRetries() =>
EndpointSetup<DefaultServer>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down