fix(store-and-forward): resolve StoreAndForward-003, re-triage 002 — fix retry-count off-by-one
This commit is contained in:
@@ -148,13 +148,14 @@ public class StoreAndForwardService
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Transient failure — buffer for retry
|
||||
// Transient failure — buffer for retry. The immediate attempt is
|
||||
// attempt 0; RetryCount tracks only sweep retries, so it stays 0
|
||||
// here (StoreAndForward-003).
|
||||
_logger.LogWarning(ex,
|
||||
"Immediate delivery to {Target} failed (transient), buffering for retry",
|
||||
target);
|
||||
|
||||
message.LastAttemptAt = DateTimeOffset.UtcNow;
|
||||
message.RetryCount = 1;
|
||||
message.LastError = ex.Message;
|
||||
await BufferAsync(message);
|
||||
|
||||
@@ -165,11 +166,11 @@ public class StoreAndForwardService
|
||||
|
||||
// Either no handler is registered yet, or the caller already attempted
|
||||
// delivery itself — buffer for the background retry sweep to deliver.
|
||||
// The initial attempt (caller-made, or skipped because no handler is
|
||||
// registered) is attempt 0; RetryCount tracks only sweep retries and
|
||||
// therefore stays 0 here (StoreAndForward-003).
|
||||
if (!attemptImmediateDelivery)
|
||||
{
|
||||
// The caller made (and failed) one attempt before handing the
|
||||
// message over, so it counts as the first retry.
|
||||
message.RetryCount = 1;
|
||||
message.LastAttemptAt = DateTimeOffset.UtcNow;
|
||||
}
|
||||
await BufferAsync(message);
|
||||
|
||||
Reference in New Issue
Block a user