Add sync way to retry in InlineSendingAgent#1614
Merged
jeremydmiller merged 2 commits intoJasperFx:mainfrom Aug 6, 2025
Merged
Add sync way to retry in InlineSendingAgent#1614jeremydmiller merged 2 commits intoJasperFx:mainfrom
jeremydmiller merged 2 commits intoJasperFx:mainfrom
Conversation
dominikjeske
commented
Aug 1, 2025
| Endpoint = endpoint; | ||
|
|
||
| if (endpoint.TelemetryEnabled) | ||
| if (settings.UseSyncRetryBlock) |
Contributor
Author
There was a problem hiding this comment.
We use optional property to switch to different behavior so no breaking change is added
dominikjeske
commented
Aug 1, 2025
| /// Abstract a way we can retry on <typeparamref name="T"/> message | ||
| /// </summary> | ||
| /// <typeparam name="T"></typeparam> | ||
| internal interface IRetryBlock<T> : IDisposable |
Contributor
Author
There was a problem hiding this comment.
Abstraction for retry logic
dominikjeske
commented
Aug 1, 2025
|
|
||
| Post(message); | ||
|
|
||
| return _block.Completion; |
Contributor
Author
There was a problem hiding this comment.
In this version we are returning Task from ActionBlock
dominikjeske
commented
Aug 1, 2025
| await _handler.ExecuteAsync(item.Message, _cancellationToken); | ||
| _logger.LogDebug("Completed {Item}", item.Message); | ||
|
|
||
| _block.Complete(); |
dominikjeske
commented
Aug 1, 2025
| /// When this option is enabled retry block used in InlineSendingAgent will synchronously wait on sending task to assure the message is send. | ||
| /// When set to <see langword="false"/> default behavior is used so InlineSendingAgent agent will try to send a message and when failed it will give control to caller and retry on other thread in async manner | ||
| /// </summary> | ||
| public bool UseSyncRetryBlock { get; set; } |
Contributor
Author
There was a problem hiding this comment.
Option to drive sending agent
dominikjeske
commented
Aug 4, 2025
| private readonly CancellationToken _cancellationToken = cancellationToken; | ||
| private readonly Func<T, CancellationToken, Task> _handler = handler; | ||
| private readonly ILogger _logger = logger; | ||
| public TimeSpan[] Pauses { get; set; } = [0.Milliseconds(), 50.Milliseconds(), 100.Milliseconds(), 250.Milliseconds()]; |
Contributor
Author
There was a problem hiding this comment.
Maybe move this Pauses to DurabilitySettings so retry logic could be configurable?
420ed6a to
4bae351
Compare
dominikjeske
commented
Aug 4, 2025
| using var activity = WolverineTracing.StartSending(e); | ||
| try | ||
| { | ||
| //TODO: What about cancellationToken?? |
Contributor
Author
There was a problem hiding this comment.
cancellationToken is not passed to Sender.SendAsync - I think it should be
Member
There was a problem hiding this comment.
Didn't make sense before when it was truly asynchronous
This was referenced Aug 6, 2025
This was referenced Mar 1, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.