Skip to content
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

Upgrade to RabbitMQ 7 #34

Merged
merged 3 commits into from
Nov 25, 2024
Merged

Upgrade to RabbitMQ 7 #34

merged 3 commits into from
Nov 25, 2024

Conversation

niemyjski
Copy link
Member

@niemyjski niemyjski commented Nov 22, 2024

Looks like this client release may have a lot of performance gains which we should monitor

image

Followed https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/main/v7-MIGRATION.md

@niemyjski niemyjski requested a review from ejsmith November 22, 2024 18:07
@niemyjski niemyjski self-assigned this Nov 22, 2024
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>netstandard2.1</TargetFrameworks>
Copy link
Member Author

Choose a reason for hiding this comment

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

Needed for IAsyncDisposable (unless we add a nuget package ref)

_factory = new ConnectionFactory
{
Uri = new Uri(options.ConnectionString),
AutomaticRecoveryEnabled = true,
DispatchConsumersAsync = true
Copy link
Member Author

Choose a reason for hiding this comment

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

This was removed and added to IConnection but looking through all the rabbit code I don't see any usages or how to set this.

Comment on lines +73 to +74
await _subscriberChannel.DisposeAsync().AnyContext();
await _subscriberConnection.DisposeAsync().AnyContext();
Copy link
Member Author

Choose a reason for hiding this comment

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

Dispose will automatically look at if it's open and call abort without throwing. I've updated all usages of the code to call this instead.

GC.SuppressFinalize(this);
}

public async ValueTask DisposeAsync()
Copy link
Member Author

Choose a reason for hiding this comment

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

_publisherModel.Abort();
_publisherModel.Dispose();
_publisherModel = null;
_publisherChannel.Dispose();
Copy link
Member Author

Choose a reason for hiding this comment

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

I implemented this twice due to a lot less async/sync mix. Their dispose under the hood is now doing GetAwaiter().GetResult() but only if it's open, the rest is sync.

if (_logger.IsEnabled(LogLevel.Information)) _logger.LogInformation(ex, "Not able to create x-delayed-type exchange");
success = false;
}
_logger.LogInformation(ex, "Unable to create x-delayed-type exchange: {Message}", ex.Message);
Copy link
Member Author

Choose a reason for hiding this comment

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

There is a bug here where success could be true even though it threw an exception which I think is wrong. I can change this back. But if it can't be thrown in the lasted rabbit 4.x the status reply code is 406. I'm not sure why it changed but this seems like a safer implementation.

cc @ejsmith @twehner

@niemyjski niemyjski merged commit c1c7ae9 into main Nov 25, 2024
3 checks passed
@niemyjski niemyjski deleted the feature/rabbitmq7 branch November 25, 2024 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant