Requests a specific quality of service (QoS).
async amqpclassic.setQoS(channelName : string, prefetchSize : number, prefetchCount : number, global : boolean): Promise<void>
This method is used to request a specific quality of service for a certain scope. When the PrefetchSize and/or PrefetchCount are set for a certain scope, the server will limit how many messages it sends to the class before stopping to wait for or or more of them to be acknowledged.
ChannelName is the name of the channel which is used to send the request. Depending on the server and what Global is set to, it may also be significant to the request itself (refer to the Global parameter's description, below, for more information).
PrefetchSize specifies a window size in bytes; i.e., the server will stop sending messages if the total size of all of the currently unacknowledged messages already sent, plus the size of the next message that could be sent, exceeds PrefetchSize bytes. A PrefetchSize of 0 indicates no limit. (Note that RabbitMQ does not support prefetch size limits.)
PrefetchCount specifies the number of unacknowledged messages the server will limit itself to sending. A PrefetchCount of 0 indicates no limit.
Global specifies the scope which the QoS request should apply to. It is interpreted differently based on whether the server is RabbitMQ or not. Refer to this table:
|Global is...||RabbitMQ||Other Servers|
|False||QoS will be applied individually to each new consumer on the specified channel (existing consumers are unaffected).||QoS applied to all existing and new consumers on the specified channel.|
|True||QoS applied to all existing and new consumers on the specified channel.||QoS applied to all existing and new consumers on the whole connection.|
Keep the following things in mind when using QoS:
- The limits specified by a QoS request only affect messages that require acknowledgement.
- How the server chooses to handle interactions between QoS settings at different scopes is server-dependent.
An exception is thrown if no channel with the given ChannelName exists, or if the server returns an error for any reason.
Note that in AMQP, server errors are grouped into "connection errors" and "channel errors", and both are fatal. That is, if the server returns a channel error, it will then close the channel which caused the error; and if it returns a connection error, it will then close the connection. The AMQPClassic class's Error Codes page includes AMQP's various connection and channel errors.