Skip to content

Conversation

niemyjski
Copy link
Member

Configures channel QoS (Quality of Service) settings, allowing control over message prefetching. This improves message processing by limiting the number and size of unacknowledged messages a consumer can have. Adds options to configure prefetch count, prefetch size, and global QoS settings.

Configures channel QoS (Quality of Service) settings, allowing control over message prefetching.
This improves message processing by limiting the number and size of unacknowledged messages a consumer can have.
Adds options to configure prefetch count, prefetch size, and global QoS settings.
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces Quality of Service (QoS) controls to the RabbitMQ message bus, allowing consumers to limit the number and total size of unacknowledged messages, and to apply these limits globally or per channel.

  • Added PrefetchCount, PrefetchSize, and GlobalQos options to configure consumer prefetch behavior.
  • Provided corresponding fluent builder methods in RabbitMQMessageBusOptionsBuilder.
  • Updated subscription logic to call BasicQosAsync when QoS settings are specified and log the applied settings.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Foundatio.RabbitMQ/Messaging/RabbitMQMessageBusOptions.cs Adds QoS properties and builder methods for prefetch count, size, and global application
src/Foundatio.RabbitMQ/Messaging/RabbitMQMessageBus.cs Calls BasicQosAsync with new options when subscribing and logs the configuration
Comments suppressed due to low confidence (2)

src/Foundatio.RabbitMQ/Messaging/RabbitMQMessageBus.cs:90

  • Add unit tests for the new QoS logic to verify that BasicQosAsync is called with the correct parameters across different combinations of PrefetchCount, PrefetchSize, and GlobalQos.
            if (_options.PrefetchCount > 0 || _options.PrefetchSize > 0)

src/Foundatio.RabbitMQ/Messaging/RabbitMQMessageBusOptions.cs:119

  • Provide XML documentation comments for the PrefetchCount, PrefetchSize, and GlobalQos builder methods to maintain consistency with other fluent API methods.
    public RabbitMQMessageBusOptionsBuilder PrefetchCount(ushort prefetchCount)

string queueName = await CreateQueueAsync(_subscriberChannel).AnyContext();

// Set QoS (Quality of Service) settings for the consumer
if (_options.PrefetchCount > 0 || _options.PrefetchSize > 0)
Copy link
Preview

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

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

The condition skips applying QoS when both PrefetchCount and PrefetchSize are zero, even if GlobalQos is true. Consider extending the check to || _options.GlobalQos so that global QoS is always applied when requested.

Suggested change
if (_options.PrefetchCount > 0 || _options.PrefetchSize > 0)
if (_options.PrefetchCount > 0 || _options.PrefetchSize > 0 || _options.GlobalQos)

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@ejsmith ejsmith left a comment

Choose a reason for hiding this comment

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

Seems fine to me.

@niemyjski niemyjski merged commit 312630e into main Jul 3, 2025
3 checks passed
@niemyjski niemyjski deleted the feature/subscriber-qos-prefetching branch July 3, 2025 19:51
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.

2 participants