-
Notifications
You must be signed in to change notification settings - Fork 7
Upgrade to .NET 8, async RabbitMQ, and modern C# features #3
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
78a83fa
d7bb43e
f83036a
0152cc2
90853ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,35 +11,35 @@ internal class MessageManager : IMessageSender, IDisposable | |||||||||
| private const string MaxPriorityHeader = "x-max-priority"; | ||||||||||
|
|
||||||||||
| internal IConnection Connection { get; private set; } | ||||||||||
|
|
||||||||||
| internal IModel Channel { get; private set; } | ||||||||||
| internal IChannel Channel { get; private set; } | ||||||||||
|
|
||||||||||
| private readonly MessageManagerSettings messageManagerSettings; | ||||||||||
| private readonly QueueSettings queueSettings; | ||||||||||
|
|
||||||||||
| public MessageManager(MessageManagerSettings messageManagerSettings, QueueSettings queueSettings) | ||||||||||
| { | ||||||||||
| var factory = new ConnectionFactory { Uri = new Uri(messageManagerSettings.ConnectionString) }; | ||||||||||
| Connection = factory.CreateConnection(); | ||||||||||
|
|
||||||||||
| Channel = Connection.CreateModel(); | ||||||||||
| Connection = factory.CreateConnectionAsync().GetAwaiter().GetResult(); | ||||||||||
| Channel = Connection.CreateChannelAsync().GetAwaiter().GetResult(); | ||||||||||
|
AngeloDotNet marked this conversation as resolved.
Outdated
|
||||||||||
|
|
||||||||||
| if (messageManagerSettings.QueuePrefetchCount > 0) | ||||||||||
| { | ||||||||||
| Channel.BasicQos(0, messageManagerSettings.QueuePrefetchCount, false); | ||||||||||
| Channel.BasicQosAsync(0, messageManagerSettings.QueuePrefetchCount, false); | ||||||||||
|
AngeloDotNet marked this conversation as resolved.
Outdated
AngeloDotNet marked this conversation as resolved.
Outdated
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| Channel.ExchangeDeclare(messageManagerSettings.ExchangeName, ExchangeType.Direct, durable: true); | ||||||||||
| Channel.ExchangeDeclareAsync(messageManagerSettings.ExchangeName, ExchangeType.Direct, durable: true); | ||||||||||
|
AngeloDotNet marked this conversation as resolved.
Outdated
|
||||||||||
| Channel.ExchangeDeclareAsync(messageManagerSettings.ExchangeName, ExchangeType.Direct, durable: true); | |
| Channel.ExchangeDeclareAsync(messageManagerSettings.ExchangeName, ExchangeType.Direct, durable: true).GetAwaiter().GetResult(); |
Copilot
AI
Dec 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The async methods QueueDeclareAsync and QueueBindAsync are called without awaiting. This fire-and-forget pattern means queues may not be properly configured before the application starts consuming messages, potentially causing runtime failures. Both calls should be awaited using GetAwaiter().GetResult() for consistency with the constructor pattern.
| Channel.QueueDeclareAsync(queue.Name, durable: true, exclusive: false, autoDelete: false, args); | |
| Channel.QueueBindAsync(queue.Name, messageManagerSettings.ExchangeName, queue.Name, null); | |
| Channel.QueueDeclareAsync(queue.Name, durable: true, exclusive: false, autoDelete: false, args).GetAwaiter().GetResult(); | |
| Channel.QueueBindAsync(queue.Name, messageManagerSettings.ExchangeName, queue.Name, null).GetAwaiter().GetResult(); |
Uh oh!
There was an error while loading. Please reload this page.