Skip to content

Conversation

dominikjeske
Copy link
Contributor

No description provided.

@@ -20,16 +20,18 @@ public InlineSendingAgent(ILogger logger, ISender sender, Endpoint endpoint, IMe
_settings = settings;
Endpoint = endpoint;

if (endpoint.TelemetryEnabled)
if (settings.UseSyncRetryBlock)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use optional property to switch to different behavior so no breaking change is added

/// Abstract a way we can retry on <typeparamref name="T"/> message
/// </summary>
/// <typeparam name="T"></typeparam>
internal interface IRetryBlock<T> : IDisposable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abstraction for retry logic


Post(message);

return _block.Completion;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this version we are returning Task from ActionBlock

await _handler.ExecuteAsync(item.Message, _cancellationToken);
_logger.LogDebug("Completed {Item}", item.Message);

_block.Complete();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Success

/// 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; }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option to drive sending agent

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()];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this Pauses to DurabilitySettings so retry logic could be configurable?

public ISender Sender { get; }

private async Task sendWithTracing(Envelope e, CancellationToken cancellationToken)
{
using var activity = WolverineTracing.StartSending(e);
try
{
//TODO: What about cancellationToken??
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cancellationToken is not passed to Sender.SendAsync - I think it should be

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't make sense before when it was truly asynchronous

@jeremydmiller jeremydmiller marked this pull request as ready for review August 6, 2025 01:01
@jeremydmiller jeremydmiller merged commit a52f56e into JasperFx:main Aug 6, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants