forked from akkadotnet/akka.net
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work on
ConsumerController
deadlock (akkadotnet#7092)
* added XML-DOC comments to current `ConsumerController.Settings` working on akkadotnet#7088 * Add `RetryConfirmation` to `ConsumerController` settings * Add retry handling during message confirmation * Add specs * Add anti-specs and settings tests * Update API approval list * Update XML-Doc and configuration comments * Shorten retry time --------- Co-authored-by: Gregorius Soedharmo <[email protected]>
- Loading branch information
1 parent
18247e1
commit 1c8ffc3
Showing
7 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/core/Akka.Tests/Delivery/ConsumerControllerRetryConfirmSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="ConsumerControllerRetryConfirmSpecs.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2024 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2024 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.Delivery; | ||
using Akka.Util; | ||
using FluentAssertions; | ||
using FluentAssertions.Extensions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using static Akka.Tests.Delivery.TestConsumer; | ||
|
||
namespace Akka.Tests.Delivery; | ||
|
||
public class ConsumerControllerRetryConfirmSpecs : TestKit.Xunit2.TestKit | ||
{ | ||
public static readonly Config Config = @" | ||
akka.reliable-delivery.consumer-controller { | ||
flow-control-window = 20 | ||
resend-interval-min = 500ms | ||
retry-confirmation = true | ||
}"; | ||
|
||
public ConsumerControllerRetryConfirmSpecs(ITestOutputHelper outputHelper) : base( | ||
Config.WithFallback(TestSerializer.Config).WithFallback(ZeroLengthSerializer.Config), output: outputHelper) | ||
{ | ||
} | ||
|
||
private int _idCount = 0; | ||
private int NextId() => _idCount++; | ||
private string ProducerId => $"p-{_idCount}"; | ||
|
||
[Fact] | ||
public void ConsumerController_Settings_confirmation_retry_must_not_be_set_by_default() | ||
{ | ||
var config = ConfigurationFactory.Default(); | ||
var settings = ConsumerController.Settings.Create(config.GetConfig("akka.reliable-delivery.consumer-controller")); | ||
settings.RetryConfirmation.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void ConsumerController_Settings_confirmation_retry_must_be_set() | ||
{ | ||
var settings = ConsumerController.Settings.Create(Sys); | ||
settings.RetryConfirmation.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public async Task ConsumerController_must_resend_Delivery_on_confirmation_retry() | ||
{ | ||
var id = NextId(); | ||
var consumerProbe = CreateTestProbe(); | ||
var consumerController = Sys.ActorOf(ConsumerController.Create<Job>(Sys, Option<IActorRef>.None), | ||
$"consumerController-{id}"); | ||
var producerControllerProbe = CreateTestProbe(); | ||
|
||
consumerController.Tell(new ConsumerController.Start<Job>(consumerProbe.Ref)); | ||
consumerController.Tell(new ConsumerController.RegisterToProducerController<Job>(producerControllerProbe.Ref)); | ||
await producerControllerProbe.ExpectMsgAsync<ProducerController.RegisterConsumer<Job>>(); | ||
|
||
consumerController.Tell(SequencedMessage(ProducerId, 1, producerControllerProbe.Ref)); | ||
|
||
await consumerProbe.ExpectMsgAsync<ConsumerController.Delivery<Job>>(); | ||
|
||
// expected resend | ||
await consumerProbe.ExpectMsgAsync<ConsumerController.Delivery<Job>>(1.5.Seconds()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters