Skip to content

Fix ShutdownInitiator in CloseAsync #1574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2024
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
15 changes: 12 additions & 3 deletions projects/RabbitMQ.Client/client/impl/AutorecoveringChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,21 @@ await _connection.RecoverConsumersAsync(this, newChannel, recordedEntitiesSemaph
_innerChannel.RunRecoveryEventHandlers(this);
}

public Task CloseAsync(ushort replyCode, string replyText, bool abort,
public async Task CloseAsync(ushort replyCode, string replyText, bool abort,
CancellationToken cancellationToken)
{
ThrowIfDisposed();
var args = new ShutdownEventArgs(ShutdownInitiator.Library, replyCode, replyText);
return CloseAsync(args, abort, cancellationToken);
try
{
await _innerChannel.CloseAsync(replyCode, replyText, abort, cancellationToken)
.ConfigureAwait(false);
}
finally
{
await _connection.DeleteRecordedChannelAsync(this,
channelsSemaphoreHeld: false, recordedEntitiesSemaphoreHeld: false)
.ConfigureAwait(false);
}
}

public async Task CloseAsync(ShutdownEventArgs args, bool abort,
Expand Down
1 change: 1 addition & 0 deletions projects/Test/Applications/MassPublish/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ await publishChannel.BasicPublishAsync(exchange: ExchangeName, routingKey: Routi
}

await consumeChannel.CloseAsync();
await consumeConnection.CloseAsync();
}

private static void PublishChannel_BasicNacks(object sender, BasicNackEventArgs e)
Expand Down