New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow AtLeastOnceDelivery parameters to be set from deriving classes (as intended) #3810
Changes from 6 commits
09e4cab
8e1ace6
0f0a52e
dc8113d
526777b
2d32faa
4330b19
7a215dd
e2cf449
c21c4c6
1db9ef8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,8 @@ internal class ChaosSender : AtLeastOnceDeliveryActor | |
|
||
public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); }} | ||
|
||
public ChaosSender(IActorRef destination, IActorRef probe) | ||
public ChaosSender(IActorRef destination, IActorRef probe) | ||
: base(x => x.WithRedeliverInterval(TimeSpan.FromMilliseconds(500))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a new ctor overload, see comment on the base class |
||
{ | ||
_destination = destination; | ||
Probe = probe; | ||
|
@@ -147,8 +148,6 @@ public ChaosSender(IActorRef destination, IActorRef probe) | |
_replayProcessingFailureRate = _config.GetDouble("replay-processing-failure-rate"); | ||
} | ||
|
||
public override TimeSpan RedeliverInterval { get { return TimeSpan.FromMilliseconds(500); } } | ||
|
||
public override string PersistenceId { get { return "chaosSender"; } } | ||
|
||
protected override bool ReceiveRecover(object message) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,7 +315,6 @@ public sealed class RedeliveryTick : INotInfluenceReceiveTimeout, IDeadLetterSup | |
private readonly IActorContext _context; | ||
private long _deliverySequenceNr; | ||
private ICancelable _redeliverScheduleCancelable; | ||
private readonly PersistenceSettings.AtLeastOnceDeliverySettings _settings; | ||
private ImmutableSortedDictionary<long, Delivery> _unconfirmed = ImmutableSortedDictionary<long, Delivery>.Empty; | ||
|
||
/// <summary> | ||
|
@@ -326,18 +325,21 @@ public sealed class RedeliveryTick : INotInfluenceReceiveTimeout, IDeadLetterSup | |
public AtLeastOnceDeliverySemantic(IActorContext context, PersistenceSettings.AtLeastOnceDeliverySettings settings) | ||
{ | ||
_context = context; | ||
_settings = settings; | ||
_deliverySequenceNr = 0; | ||
|
||
RedeliverInterval = settings.RedeliverInterval; | ||
RedeliveryBurstLimit = settings.RedeliveryBurstLimit; | ||
WarnAfterNumberOfUnconfirmedAttempts = settings.WarnAfterNumberOfUnconfirmedAttempts; | ||
MaxUnconfirmedMessages = settings.MaxUnconfirmedMessages; | ||
} | ||
|
||
/// <summary> | ||
/// Interval between redelivery attempts. | ||
/// | ||
/// The default value can be configure with the 'akka.persistence.at-least-once-delivery.redeliver-interval' | ||
/// configuration key. This method can be overridden by implementation classes to return | ||
/// non-default values. | ||
/// configuration key. | ||
/// </summary> | ||
public virtual TimeSpan RedeliverInterval => _settings.RedeliverInterval; | ||
public TimeSpan RedeliverInterval { get; } | ||
|
||
/// <summary> | ||
/// Maximum number of unconfirmed messages that will be sent at each redelivery burst | ||
|
@@ -346,31 +348,28 @@ public AtLeastOnceDeliverySemantic(IActorContext context, PersistenceSettings.At | |
/// this helps prevent an overwhelming amount of messages to be sent at once. | ||
/// | ||
/// The default value can be configure with the 'akka.persistence.at-least-once-delivery.redelivery-burst-limit' | ||
/// configuration key. This method can be overridden by implementation classes to return | ||
/// non-default values. | ||
/// configuration key. | ||
/// </summary> | ||
public virtual int RedeliveryBurstLimit => _settings.RedeliveryBurstLimit; | ||
public int RedeliveryBurstLimit { get; } | ||
|
||
/// <summary> | ||
/// After this number of delivery attempts a <see cref="UnconfirmedWarning" /> message will be sent to | ||
/// <see cref="ActorBase.Self" />. The count is reset after restart. | ||
/// | ||
/// The default value can be configure with the 'akka.persistence.at-least-once-delivery.warn-after-number-of-unconfirmed-attempts' | ||
/// configuration key. This method can be overridden by implementation classes to return | ||
/// non-default values. | ||
/// configuration key. | ||
/// </summary> | ||
public virtual int WarnAfterNumberOfUnconfirmedAttempts => _settings.WarnAfterNumberOfUnconfirmedAttempts; | ||
public int WarnAfterNumberOfUnconfirmedAttempts { get; } | ||
|
||
/// <summary> | ||
/// Maximum number of unconfirmed messages, that this actor is allowed to hold in the memory. | ||
/// if this number is exceeded, <see cref="AtLeastOnceDeliverySemantic.Deliver" /> will not accept more | ||
/// messages and it will throw <see cref="MaxUnconfirmedMessagesExceededException" />. | ||
/// | ||
/// The default value can be configure with the 'akka.persistence.at-least-once-delivery.max-unconfirmed-messages' | ||
/// configuration key. This method can be overridden by implementation classes to return | ||
/// non-default values. | ||
/// configuration key. | ||
/// </summary> | ||
public virtual int MaxUnconfirmedMessages => _settings.MaxUnconfirmedMessages; | ||
public int MaxUnconfirmedMessages { get; } | ||
|
||
/// <summary> | ||
/// Number of messages, that have not been confirmed yet. | ||
|
@@ -380,8 +379,8 @@ public AtLeastOnceDeliverySemantic(IActorContext context, PersistenceSettings.At | |
private void StartRedeliverTask() | ||
{ | ||
if (_redeliverScheduleCancelable != null) return; | ||
var interval = new TimeSpan(RedeliverInterval.Ticks / 2); | ||
_redeliverScheduleCancelable = _context.System.Scheduler.ScheduleTellRepeatedlyCancelable(interval, interval, _context.Self, | ||
var delay = new TimeSpan(RedeliverInterval.Ticks / 2); | ||
_redeliverScheduleCancelable = _context.System.Scheduler.ScheduleTellRepeatedlyCancelable(delay, RedeliverInterval, _context.Self, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this a bug? The first parameter is the initial delay of the very first callback. The second parameter is then the interval this will fire in, so this should be the whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, must have been a bug. Nice catch. |
||
RedeliveryTick.Instance, _context.Self); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this change.