From 1f6d90b10a7136d2ab031edb0fd5bd656f95ce33 Mon Sep 17 00:00:00 2001 From: Achilleas Anagnostopoulos Date: Wed, 2 Nov 2022 20:15:18 +0000 Subject: [PATCH] Allow channel.qos() invocations to set the value of the `global` param The value of the `global` flag is interpreted differently between the AMQP 0-9-1 spec and RabbitMQ. For RabbitMQ, if `global` is true, then `prefetchCount` is shared between all consumers of this channel. Otherwise, `prefetchCount` is applied separately to each new consumer of the channel. According to the AMQP spec, if `global` is true, then `prefetchCount` is shared between all consumers on the connection. Otherwise, `prefetchCount` is shared between all consumers of this channel. For more information see https://www.rabbitmq.com/consumer-prefetch.html --- lib/src/client/channel.dart | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/src/client/channel.dart b/lib/src/client/channel.dart index 09a98a3..927f134 100644 --- a/lib/src/client/channel.dart +++ b/lib/src/client/channel.dart @@ -49,10 +49,22 @@ abstract class Channel { bool noWait = false, Map arguments}); - /// Setup the [prefetchSize] and [prefetchCount] QoS parameters. + /// Setup the [prefetchSize] and [prefetchCount] QoS parameters. The value + /// of the [global] flag is interpreted differently between the AMQP 0-9-1 + /// spec and RabbitMQ. + /// + /// For RabbitMQ, if [global] is true, then [prefetchCount] is shared between + /// all consumers of this channel. Otherwise, [prefetchCount] is applied + /// separately to each new consumer of the channel. + /// + /// According to the AMQP spec, if [global] is true, then [prefetchCount] is + /// shared between all consumers on the connection. Otherwise, + /// [prefetchCount] is shared between all consumers of this channel. + /// /// Returns a [Future] with the affected channel once the server /// confirms the updated QoS settings. - Future qos(int? prefetchSize, int? prefetchCount); + Future qos(int? prefetchSize, int? prefetchCount, + {bool global = true}); /// Acknowledge a [deliveryTag]. The [multiple] flag can be set to true /// to notify the server that the client ack-ed all pending messages up to [deliveryTag].