Fixed Flow response messages blocking the consumer

Caused by non-async disposable payload in MessageContext never being disposed
This commit is contained in:
Mark van Renswoude 2021-09-16 12:26:11 +02:00
parent 04182ad9bd
commit a9a38f2497
2 changed files with 11 additions and 11 deletions

View File

@ -8,7 +8,7 @@ namespace Tapeti.Config
/// <summary>
/// Provides information about the message currently being handled.
/// </summary>
public interface IMessageContext : IAsyncDisposable, IDisposable
public interface IMessageContext : IAsyncDisposable
{
/// <summary>
/// Provides access to the Tapeti config.

View File

@ -66,21 +66,21 @@ namespace Tapeti.Default
}
/// <inheritdoc />
public void Dispose()
{
foreach (var payload in payloads.Values)
(payload as IDisposable)?.Dispose();
}
/// <inheritdoc />
public async ValueTask DisposeAsync()
{
foreach (var payload in payloads.Values)
{
if (payload is IAsyncDisposable asyncDisposable)
await asyncDisposable.DisposeAsync();
switch (payload)
{
case IAsyncDisposable asyncDisposable:
await asyncDisposable.DisposeAsync();
break;
case IDisposable disposable:
disposable.Dispose();
break;
}
}
}