Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}
}

public IHandlerPipeline? Pipeline { get; }

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 111 in src/Wolverine/Runtime/WorkerQueues/BufferedReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? BufferedReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

public Uri Uri { get; }

Expand All @@ -124,19 +124,27 @@

public async ValueTask DrainAsync()
{
// If _latched was already true, this drain was triggered during shutdown
// (after OnApplicationStopping called Latch()). Safe to wait for in-flight items.
// If _latched was false, this drain may have been triggered from within the handler
// pipeline (e.g., rate limiting pause via PauseListenerContinuation). Waiting for
// the receiving block to complete would deadlock because the current message's
// execute function is still on the call stack.
var waitForCompletion = _latched;
_latched = true;
_receivingBlock.Complete();

// Wait for in-flight handler executions to complete, bounded by a timeout
// to prevent hanging during shutdown
try
{
var completion = _receivingBlock.WaitForCompletionAsync();
await Task.WhenAny(completion, Task.Delay(_settings.DrainTimeout));
}
catch (Exception e)
if (waitForCompletion)
{
_logger.LogDebug(e, "Error waiting for in-flight message processing to complete at {Uri}", Uri);
try
{
var completion = _receivingBlock.WaitForCompletionAsync();
await Task.WhenAny(completion, Task.Delay(_settings.DrainTimeout));
}
catch (Exception e)
{
_logger.LogDebug(e, "Error waiting for in-flight message processing to complete at {Uri}", Uri);
}
}

await _completeBlock.DrainAsync();
Expand Down
26 changes: 17 additions & 9 deletions src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
await EnqueueAsync(envelope);
}

public IHandlerPipeline? Pipeline { get; }

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

Check warning on line 212 in src/Wolverine/Runtime/WorkerQueues/DurableReceiver.cs

View workflow job for this annotation

GitHub Actions / test

Nullability of reference types in return type of 'IHandlerPipeline? DurableReceiver.Pipeline.get' doesn't match implicitly implemented member 'IHandlerPipeline IReceiver.Pipeline.get' (possibly because of nullability attributes).

public Uri Uri { get; set; }

Expand Down Expand Up @@ -283,19 +283,27 @@

public async ValueTask DrainAsync()
{
// If _latched was already true, this drain was triggered during shutdown
// (after OnApplicationStopping called Latch()). Safe to wait for in-flight items.
// If _latched was false, this drain may have been triggered from within the handler
// pipeline (e.g., rate limiting pause via PauseListenerContinuation). Waiting for
// the receiver block to complete would deadlock because the current message's
// execute function is still on the call stack.
var waitForCompletion = _latched;
_latched = true;
_receiver.Complete();

// Wait for in-flight handler executions to complete, bounded by a timeout
// to prevent hanging during shutdown
try
{
var completion = _receiver.WaitForCompletionAsync();
await Task.WhenAny(completion, Task.Delay(_settings.DrainTimeout));
}
catch (Exception e)
if (waitForCompletion)
{
_logger.LogDebug(e, "Error waiting for in-flight message processing to complete at {Uri}", Uri);
try
{
var completion = _receiver.WaitForCompletionAsync();
await Task.WhenAny(completion, Task.Delay(_settings.DrainTimeout));
}
catch (Exception e)
{
_logger.LogDebug(e, "Error waiting for in-flight message processing to complete at {Uri}", Uri);
}
}

await _incrementAttempts.DrainAsync();
Expand Down
Loading