Skip to content

update: migrate RabbitMQ operations to async methods +semver: minor#953

Merged
guibranco merged 3 commits into
mainfrom
feature/596-upgrade-rabbitmq-client-library-to-version-700
Jul 4, 2026
Merged

update: migrate RabbitMQ operations to async methods +semver: minor#953
guibranco merged 3 commits into
mainfrom
feature/596-upgrade-rabbitmq-client-library-to-version-700

Conversation

@guibranco

@guibranco guibranco commented Jul 4, 2026

Copy link
Copy Markdown
Owner

πŸ“‘ Description

  • Upgrade RabbitMQ.Client package from version 6.8.1 to 7.0.0.
  • Modify MessageReceiver, RabbitMQLogProvider, and RabbitMQWrapper classes to use asynchronous methods for RabbitMQ operations.
  • Change method names in MessageReceiver to DoWorkAsync and adapt logic to use AsyncEventingBasicConsumer.
  • Use async versions of CreateConnection, CreateChannel, QueueDeclare, and BasicPublish methods across the affected classes.
  • Improve graceful shutdown handling in MessageReceiver using OperationCanceledException.

These changes enhance the scalability and responsiveness of the RabbitMQ operations by leveraging asynchronous programming.

βœ… Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

☒️ Does this introduce a breaking change?

  • Yes
  • No

Summary by Sourcery

Migrate RabbitMQ integration to the client library’s asynchronous APIs to improve scalability and cancellation-aware processing.

New Features:

  • Introduce asynchronous send operations for publishing messages to RabbitMQ exchanges and queues.
  • Enable asynchronous, cancellation-aware message consumption from RabbitMQ queues and exchanges.

Enhancements:

  • Update RabbitMQ logging provider to use async channel and exchange operations while preserving the existing worker-thread model.

Build:

  • Upgrade RabbitMQ.Client dependency to version 7.0.0.

Summary by CodeRabbit

  • New Features

    • RabbitMQ send and receive operations now run asynchronously and support cancellation for smoother background processing.
    • Message publishing now uses updated messaging behavior for more reliable delivery.
  • Bug Fixes

    • Improved shutdown handling for message consumers to reduce hanging or blocked processes.
  • Chores

    • Updated the RabbitMQ client library version.
    • Refreshed the linter workflow to use the latest action version.

- Upgrade `RabbitMQ.Client` package from version 6.8.1 to 7.0.0.
- Modify `MessageReceiver`, `RabbitMQLogProvider`, and `RabbitMQWrapper`
  classes to use asynchronous methods for RabbitMQ operations.
- Change method names in `MessageReceiver` to `DoWorkAsync` and adapt
  logic to use `AsyncEventingBasicConsumer`.
- Use `async` versions of `CreateConnection`, `CreateChannel`, `QueueDeclare`,
  and `BasicPublish` methods across the affected classes.
- Improve graceful shutdown handling in `MessageReceiver` using
  `OperationCanceledException`.

These changes enhance the scalability and responsiveness of the
RabbitMQ operations by leveraging asynchronous programming.
@guibranco guibranco linked an issue Jul 4, 2026 that may be closed by this pull request
@sourcery-ai

sourcery-ai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

Migrates RabbitMQ usage from synchronous to asynchronous APIs across message receiving, publishing, and logging, aligned with the RabbitMQ.Client 7.x async model and improved cancellation-aware shutdown.

Sequence diagram for asynchronous message receiving with cancellation-aware shutdown

sequenceDiagram
    participant Application
    participant MessageReceiver
    participant ConnectionFactory
    participant Connection
    participant Channel
    participant AsyncConsumer
    participant Subscriber

    Application->>MessageReceiver: ReceiveFromQueue<T>(autoAck, cancellationToken)
    MessageReceiver->>MessageReceiver: DoWorkAsync("", queueName, autoAck, cancellationToken)
    MessageReceiver->>ConnectionFactory: CreateConnectionAsync(cancellationToken)
    ConnectionFactory-->>MessageReceiver: connection
    MessageReceiver->>Connection: CreateChannelAsync(cancellationToken)
    Connection-->>MessageReceiver: channel
    MessageReceiver->>Channel: QueueDeclareAsync(cancellationToken)
    Channel-->>MessageReceiver: queueName
    MessageReceiver->>Channel: QueueBindAsync(queueName, exchange, "", cancellationToken)
    MessageReceiver->>AsyncConsumer: new AsyncEventingBasicConsumer(channel)
    MessageReceiver->>Channel: BasicConsumeAsync(queueName, autoAck, AsyncConsumer, cancellationToken)

    AsyncConsumer-->>MessageReceiver: ReceivedAsync(sender, args)
    MessageReceiver->>Subscriber: MessageReceived(this, MessageReceivedArgs)

    MessageReceiver->>MessageReceiver: Task.Delay(Timeout.Infinite, cancellationToken)
    Note over MessageReceiver: Throws OperationCanceledException on cancellation
    MessageReceiver-->>Application: graceful shutdown
Loading

Sequence diagram for asynchronous message publishing via RabbitMQWrapper

sequenceDiagram
    participant Application
    participant RabbitMQWrapper
    participant ConnectionFactory
    participant Connection
    participant Channel

    Application->>RabbitMQWrapper: SendToExchangeAsync<T>(item, exchangeDeclareType, cancellationToken)
    RabbitMQWrapper->>ConnectionFactory: CreateConnectionAsync(cancellationToken)
    ConnectionFactory-->>RabbitMQWrapper: connection
    RabbitMQWrapper->>Connection: CreateChannelAsync(cancellationToken)
    Connection-->>RabbitMQWrapper: channel
    RabbitMQWrapper->>Channel: ExchangeDeclareAsync(exchangeName, exchangeDeclareType, true, false, cancellationToken)
    RabbitMQWrapper->>RabbitMQWrapper: item.GetSerializer()
    RabbitMQWrapper->>Channel: BasicPublishAsync(exchangeName, "", false, BasicProperties{Persistent=true}, body, cancellationToken)

    Application->>RabbitMQWrapper: SendToQueueAsync<T>(item, queueDeclare, cancellationToken)
    RabbitMQWrapper->>ConnectionFactory: CreateConnectionAsync(cancellationToken)
    ConnectionFactory-->>RabbitMQWrapper: connection
    RabbitMQWrapper->>Connection: CreateChannelAsync(cancellationToken)
    Connection-->>RabbitMQWrapper: channel
    RabbitMQWrapper->>Channel: QueueDeclareAsync(queueName, true, false, false, cancellationToken)
    RabbitMQWrapper->>RabbitMQWrapper: item.GetSerializer()
    RabbitMQWrapper->>Channel: BasicPublishAsync("", queueName, false, BasicProperties{Persistent=true}, body, cancellationToken)
Loading

File-Level Changes

Change Details Files
Refactor MessageReceiver to use async RabbitMQ APIs and AsyncEventingBasicConsumer with cancellation-aware lifetime management.
  • Rename internal worker method to DoWorkAsync and make it asynchronous, returning Task instead of void.
  • Use CreateConnectionAsync, CreateChannelAsync, QueueDeclareAsync, QueueBindAsync, and BasicConsumeAsync on the connector’s factory/channel, wiring up an AsyncEventingBasicConsumer and ReceivedAsync handler.
  • Replace WaitHandle.WaitOne blocking loop with Task.Delay using the provided CancellationToken and handle OperationCanceledException for graceful shutdown.
  • Update ReceiveFromQueue and ReceiveFromExchange entrypoints to start the new DoWorkAsync method in a background Task.
Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs
Convert RabbitMQWrapper send operations to asynchronous methods using the new async channel and publishing APIs.
  • Introduce SendToExchangeAsync and SendToQueueAsync async methods with optional CancellationToken parameters.
  • Obtain connections and channels via CreateConnectionAsync and CreateChannelAsync and dispose them with await using.
  • Use ExchangeDeclareAsync and QueueDeclareAsync where applicable instead of synchronous declare calls.
  • Publish messages via BasicPublishAsync using BasicProperties with Persistent set to true, replacing synchronous BasicPublish.
Src/CrispyWaffle.RabbitMQ/Utils/Communications/RabbitMQWrapper.cs
Update RabbitMQLogProvider to rely on async connection/channel creation and async publishing/closing while keeping a synchronous worker thread.
  • Change channel type from IModel to IChannel to match the new async RabbitMQ.Client API.
  • In the constructor, create the connection and channel using CreateConnectionAsync and CreateChannelAsync, and declare the log exchange via ExchangeDeclareAsync, all invoked synchronously with GetAwaiter().GetResult().
  • Modify PropagateMessageInternal to call BasicPublishAsync with the default exchange and log message body, blocking on completion via GetAwaiter().GetResult().
  • Adjust Dispose to close the channel using CloseAsync and then Dispose, ensuring resources are released in the async model.
Src/CrispyWaffle.RabbitMQ/Log/RabbitMQLogProvider.cs
Upgrade RabbitMQ.Client dependency to version 7.0.0 to enable async APIs.
  • Update the RabbitMQ.Client package version in central package management props file to 7.0.0.
  • Aligns all RabbitMQ-related code with the new interfaces and async methods provided by the 7.x client.
Directory.Packages.props

Assessment against linked issues

Issue Objective Addressed Explanation
#596 Update the RabbitMQ.Client dependency to version 7.0.0. βœ…
#596 Modify RabbitMQ-related code to be compatible with RabbitMQ.Client 7.0.0, including handling any breaking changes. βœ…
#596 Update project documentation (where applicable) to reflect the upgraded RabbitMQ.Client version and any relevant behavioral changes. βœ…

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 4, 2026
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Upgrades RabbitMQ.Client from 6.8.1 to 7.0.0 and refactors RabbitMQ consumption (MessageReceiver), log publishing (RabbitMQLogProvider), and message publishing (RabbitMQWrapper) from synchronous to async/await APIs with cancellation token support. Also updates the CSharpier linter GitHub Action reference to @latest.

Changes

RabbitMQ.Client 7.0.0 async migration

Layer / File(s) Summary
Package version bump
Directory.Packages.props
RabbitMQ.Client updated from 6.8.1 to 7.0.0 in centralized package management.
Async message consumption
Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs
DoWork replaced with DoWorkAsync; uses async connection/channel creation, AsyncEventingBasicConsumer, and Task.Delay with CancellationToken for lifetime management, replacing blocking WaitHandle.WaitOne().
Async log publishing
Src/CrispyWaffle.RabbitMQ/Log/RabbitMQLogProvider.cs
_channel changed to IChannel; constructor, message publish, and dispose logic converted to async RabbitMQ APIs, synchronously awaited via GetAwaiter().GetResult().
Async message publishing
Src/CrispyWaffle.RabbitMQ/Utils/Communications/RabbitMQWrapper.cs
SendToExchange/SendToQueue replaced with SendToExchangeAsync/SendToQueueAsync (returning Task, accepting CancellationToken); use async connection/channel creation, declarations, and BasicPublishAsync with BasicProperties.
CI linter action update
.github/workflows/linter.yml
CSharpier Linter step's uses directive changed from a pinned commit SHA to @latest.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant MessageReceiver
  participant Channel as IChannel
  participant Consumer as AsyncEventingBasicConsumer

  Caller->>MessageReceiver: ReceiveFromQueue/ReceiveFromExchange
  MessageReceiver->>MessageReceiver: DoWorkAsync(queue/exchange, autoAck, cancellationToken)
  MessageReceiver->>Channel: CreateConnectionAsync/CreateChannelAsync
  MessageReceiver->>Channel: QueueDeclareAsync/QueueBindAsync
  MessageReceiver->>Consumer: register ReceivedAsync callback
  Consumer-->>MessageReceiver: message body received
  MessageReceiver->>MessageReceiver: raise MessageReceived event
  MessageReceiver->>MessageReceiver: await Task.Delay until cancelled
Loading
sequenceDiagram
  participant Caller
  participant RabbitMQWrapper
  participant Channel as IChannel
  participant Broker as RabbitMQ Broker

  Caller->>RabbitMQWrapper: SendToExchangeAsync/SendToQueueAsync(item, cancellationToken)
  RabbitMQWrapper->>Channel: CreateConnectionAsync/CreateChannelAsync
  RabbitMQWrapper->>Channel: ExchangeDeclareAsync/QueueDeclareAsync (if configured)
  RabbitMQWrapper->>Channel: BasicPublishAsync(serialized item, BasicProperties)
  Channel->>Broker: publish message
  Channel-->>RabbitMQWrapper: dispose channel/connection (await using)
Loading

Possibly related issues

Suggested labels: enhancement, communications, .NET

Suggested reviewers: gstraccini

Poem

A rabbit hopped through async streams,
Await, await, in flowing themes,
No more blocking, no more wait,
Channels dance through RabbitMQ's gate,
Version seven, swift and bright,
Hop hop hooray, the code's just right! πŸ‡βœ¨

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly summarizes the main change: migrating RabbitMQ operations to async methods, with the semver note matching the scope.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/596-upgrade-rabbitmq-client-library-to-version-700

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

πŸ”₯ Formatting issues detected

File Line
./Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs 120

⚑ Please run dotnet csharpier . locally to fix the formatting issues.

@socket-security

socket-security Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednuget/​rabbitmq.client@​6.8.1 ⏡ 7.0.0981009010090

View full report

@socket-security

socket-security Bot commented Jul 4, 2026

Copy link
Copy Markdown

Caution

Review the following alerts detected in dependencies.

According to your organization's Security Policy, you must resolve all "Block" alerts before proceeding. Learn more about Socket for GitHub.

Action Severity Alert  (click "β–Ά" to expand/collapse)
Block Medium
System shell access: nuget system.threading.ratelimiting

Location: Package overview

From: Src/CrispyWaffle.RabbitMQ/CrispyWaffle.RabbitMQ.csproj β†’ nuget/rabbitmq.client@7.0.0 β†’ nuget/system.threading.ratelimiting@8.0.0

β„Ή Read more on: This package | This alert | What is shell access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should avoid accessing the shell which can reduce portability, and make it easier for malicious shell access to be introduced.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore nuget/system.threading.ratelimiting@8.0.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Medium
Dynamic code execution: nuget system.threading.ratelimiting

Location: Package overview

From: Src/CrispyWaffle.RabbitMQ/CrispyWaffle.RabbitMQ.csproj β†’ nuget/rabbitmq.client@7.0.0 β†’ nuget/system.threading.ratelimiting@8.0.0

β„Ή Read more on: This package | This alert | What is dynamic code execution?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Avoid packages that use dynamic code execution like eval(), since this could potentially execute any code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore nuget/system.threading.ratelimiting@8.0.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): nuget microsoft.bcl.asyncinterfaces is 61.0% likely to have a medium risk anomaly

Notes: The fragment is not conventional executable source code; it is a binary-like payload rich in signing-related data (certificates, OCSP/CRL references) with references to NuGet/Microsoft ecosystems. This necessitates provenance verification and strict supply-chain validation to prevent misuse or tampering in a package delivery context. Further context about how this artifact is consumed is required to determine actual risk in a given project.

Confidence: 0.61

Severity: 0.62

From: Src/CrispyWaffle.RabbitMQ/CrispyWaffle.RabbitMQ.csproj β†’ nuget/rabbitmq.client@7.0.0 β†’ nuget/microsoft.bcl.asyncinterfaces@8.0.0

β„Ή Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore nuget/microsoft.bcl.asyncinterfaces@8.0.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
Potential code anomaly (AI signal): nuget system.io.pipelines is 50.0% likely to have a medium risk anomaly

Notes: This is a .p7s file, which contains a digital signature for a document or email, using the PKCS #7 standard, which serves to verify the sender's identity and ensure the content hasn't been altered in transit.

Confidence: 0.50

Severity: 0.50

From: Src/CrispyWaffle.RabbitMQ/CrispyWaffle.RabbitMQ.csproj β†’ nuget/rabbitmq.client@7.0.0 β†’ nuget/system.io.pipelines@8.0.0

β„Ή Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore nuget/system.io.pipelines@8.0.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
License exception: nuget system.threading.channels with Classpath-exception-2.0

Exception: Classpath-exception-2.0

Comments:

From: Src/CrispyWaffle.RabbitMQ/CrispyWaffle.RabbitMQ.csproj β†’ nuget/rabbitmq.client@7.0.0 β†’ nuget/system.threading.channels@8.0.0

β„Ή Read more on: This package | This alert | What is a license exception?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: License exceptions should be carefully reviewed.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore nuget/system.threading.channels@8.0.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Block Low
License exception: nuget system.threading.ratelimiting with Classpath-exception-2.0

Exception: Classpath-exception-2.0

Comments:

From: Src/CrispyWaffle.RabbitMQ/CrispyWaffle.RabbitMQ.csproj β†’ nuget/rabbitmq.client@7.0.0 β†’ nuget/system.threading.ratelimiting@8.0.0

β„Ή Read more on: This package | This alert | What is a license exception?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: License exceptions should be carefully reviewed.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore nuget/system.threading.ratelimiting@8.0.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@guibranco

Copy link
Copy Markdown
Owner Author

@gstraccini csharpier

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The await using var connectionDisposable = connection.ConfigureAwait(false); / channelDisposable pattern is incorrect for IAsyncDisposable; you should use await using var connection = connection; (and likewise for channel) without ConfigureAwait on the disposable itself.
  • Both ReceiveFromQueue and ReceiveFromExchange are still fire-and-forget (Task.Run without awaiting the returned task), which makes exception handling and lifecycle control of the consumer harder; consider making these methods async and returning the task so callers can observe failures and manage cancellation more explicitly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `await using var connectionDisposable = connection.ConfigureAwait(false);` / `channelDisposable` pattern is incorrect for `IAsyncDisposable`; you should use `await using var connection = connection;` (and likewise for `channel`) without `ConfigureAwait` on the disposable itself.
- Both `ReceiveFromQueue` and `ReceiveFromExchange` are still fire-and-forget (`Task.Run` without awaiting the returned task), which makes exception handling and lifecycle control of the consumer harder; consider making these methods async and returning the task so callers can observe failures and manage cancellation more explicitly.

## Individual Comments

### Comment 1
<location path="Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs" line_range="106-114" />
<code_context>
+        CancellationToken cancellationToken
+    )
+    {
+        var connection = await _connector
+            .ConnectionFactory.CreateConnectionAsync(cancellationToken)
+            .ConfigureAwait(false);
+        await using var connectionDisposable = connection.ConfigureAwait(false);
+
+        var channel = await connection
+            .CreateChannelAsync(cancellationToken: cancellationToken)
+            .ConfigureAwait(false);
+        await using var channelDisposable = channel.ConfigureAwait(false);
+
+        var consumer = new AsyncEventingBasicConsumer(channel);
</code_context>
<issue_to_address>
**issue (bug_risk):** Incorrect use of ConfigureAwait with IAsyncDisposable will not compile and prevents proper disposal.

`ConfigureAwait` can only be called on `Task`/`ValueTask`, so `await using var connectionDisposable = connection.ConfigureAwait(false);` (and the equivalent for `channel`) will not compile and does not dispose the resources correctly. Instead, await the async factory methods and use `await using` directly on the resulting objects:

```csharp
await using var connection = await _connector
    .ConnectionFactory.CreateConnectionAsync(cancellationToken)
    .ConfigureAwait(false);

await using var channel = await connection
    .CreateChannelAsync(cancellationToken: cancellationToken)
    .ConfigureAwait(false);
```

This ensures the connection and channel are properly asynchronously disposed without extra `*Disposable` variables.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click πŸ‘ or πŸ‘Ž on each comment and I'll use the feedback to improve your reviews.

Comment thread Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs
Comment thread Src/CrispyWaffle.RabbitMQ/Utils/Communications/RabbitMQWrapper.cs Dismissed
Comment thread Src/CrispyWaffle.RabbitMQ/Utils/Communications/RabbitMQWrapper.cs Dismissed
Comment thread Src/CrispyWaffle.RabbitMQ/Utils/Communications/RabbitMQWrapper.cs Dismissed
Comment thread Src/CrispyWaffle.RabbitMQ/Utils/Communications/RabbitMQWrapper.cs Dismissed
@gstraccini

gstraccini Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Running CSharpier on this branch! πŸ”§

@gstraccini

gstraccini Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

βœ… CSharpier result:

Error ./Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs - Was not formatted.
  ----------------------------- Expected: Around Line 120 -----------------------------
              ? (
                  await channel
                      .QueueDeclareAsync(cancellationToken: cancellationToken)
  ----------------------------- Actual: Around Line 120 -----------------------------
              ? (
                  await channel.QueueDeclareAsync(cancellationToken: cancellationToken)
                      .ConfigureAwait(false)
  
Checked 189 files in 1093ms.

@gstraccini

gstraccini Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

ℹ️ Workflow Template updated!

A new workflow template has been added: .github/workflows/linter.yml

@guibranco
guibranco enabled auto-merge (squash) July 4, 2026 19:42
@gstraccini gstraccini Bot added β˜‘οΈ auto-merge Automatic merging of pull requests (gstraccini-bot) .NET Pull requests that update .net code communications dependencies Pull requests that update a dependency file enhancement New feature or request gitauto GitAuto label to trigger the app in a issue. hacktoberfest Participation in the Hacktoberfest event nuget RabbitMQ RabbitMQ ♻️ code quality Code quality-related tasks or issues βš™οΈ CI/CD Continuous Integration/Continuous Deployment processes πŸ‘·πŸΌ infrastructure Infrastructure-related tasks or issues πŸ“ documentation Tasks related to writing or updating documentation labels Jul 4, 2026
@gstraccini gstraccini Bot added πŸ•” high effort A task that can be completed in a few days 🚨 security Security-related issues or improvements πŸ§ͺ tests Tasks related to testing labels Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Infisical secrets check: βœ… No secrets leaked!

πŸ’» Scan logs
2026-07-04T19:42:24Z INF scanning for exposed secrets...
7:42PM INF 811 commits scanned.
2026-07-04T19:42:25Z INF scan completed in 1.26s
2026-07-04T19:42:25Z INF no leaks found

@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required β‰₯ 80%)

See analysis details on SonarQube Cloud

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/linter.yml (1)

15-15: πŸ”’ Security & Privacy | πŸ”΅ Trivial | ⚑ Quick win

Unpinned action reference (@latest) is a supply-chain and reproducibility risk.

Switching from a pinned version/commit to the mutable @latest tag means the workflow's behavior can silently change whenever the upstream action publishes a new release (or a compromised release), with no corresponding change in this repository. Prefer pinning to a specific version tag or, ideally, a commit SHA for tamper-resistance and reproducible CI runs.

πŸ”’οΈ Suggested fix
-        uses: guibranco/github-csharpier-linter-action@latest
+        uses: guibranco/github-csharpier-linter-action@v1.0.25
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/linter.yml at line 15, The workflow step using
guibranco/github-csharpier-linter-action is currently pinned to a mutable
`@latest` reference, which should be replaced with a fixed version tag or commit
SHA. Update the action reference in the linter workflow to a specific immutable
version so CI stays reproducible and resistant to upstream changes. Keep the
same action and step structure, only change the version selector to a pinned
identifier.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs`:
- Around line 55-65: The ReceiveFromQueue<T> and ReceiveFromExchange<T> startup
paths discard the Task.Run result, so failures in DoWorkAsync can be lost and
the caller never knows the consumer did not start. Update the MessageReceiver
methods to either return/await the Task from Task.Run or attach explicit
exception handling and fault logging around DoWorkAsync, and remove the
ineffective ConfigureAwait(false) on the discarded task. Use the
ReceiveFromQueue<T> and ReceiveFromExchange<T> methods to locate the change.

In `@Src/CrispyWaffle.RabbitMQ/Log/RabbitMQLogProvider.cs`:
- Around line 59-75: The RabbitMQ connection created in
RabbitMQLogProvider.Initialize is never retained or disposed, causing a resource
leak. Store the result of ConnectionFactory.CreateConnectionAsync in a dedicated
field on RabbitMQLogProvider, then use that field when creating the channel and
ensure Dispose(bool) closes and disposes both the channel and the connection.
Keep the cleanup logic aligned with the existing _channel disposal path so the
provider owns the full connection lifecycle.

---

Nitpick comments:
In @.github/workflows/linter.yml:
- Line 15: The workflow step using guibranco/github-csharpier-linter-action is
currently pinned to a mutable `@latest` reference, which should be replaced with a
fixed version tag or commit SHA. Update the action reference in the linter
workflow to a specific immutable version so CI stays reproducible and resistant
to upstream changes. Keep the same action and step structure, only change the
version selector to a pinned identifier.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 71e52877-b2e8-410e-ad7a-f1e8068b3d47

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 9d30501 and 05c1079.

πŸ“’ Files selected for processing (5)
  • .github/workflows/linter.yml
  • Directory.Packages.props
  • Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs
  • Src/CrispyWaffle.RabbitMQ/Log/RabbitMQLogProvider.cs
  • Src/CrispyWaffle.RabbitMQ/Utils/Communications/RabbitMQWrapper.cs

Comment thread Src/CrispyWaffle.RabbitMQ/Helpers/MessageReceiver.cs
Comment thread Src/CrispyWaffle.RabbitMQ/Log/RabbitMQLogProvider.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

β˜‘οΈ auto-merge Automatic merging of pull requests (gstraccini-bot) βš™οΈ CI/CD Continuous Integration/Continuous Deployment processes ♻️ code quality Code quality-related tasks or issues communications dependencies Pull requests that update a dependency file πŸ“ documentation Tasks related to writing or updating documentation enhancement New feature or request gitauto GitAuto label to trigger the app in a issue. hacktoberfest Participation in the Hacktoberfest event πŸ•” high effort A task that can be completed in a few days πŸ‘·πŸΌ infrastructure Infrastructure-related tasks or issues .NET Pull requests that update .net code nuget RabbitMQ RabbitMQ 🚨 security Security-related issues or improvements size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. πŸ§ͺ tests Tasks related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Upgrade RabbitMQ Client Library to Version 7.0.0

2 participants