azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[FEATURE REQ] Support new RateLimiter API in ServiceBusProcessor
Library name
Azure.Messaging.ServiceBus
Please describe the feature.
Microsoft just announced the System.Threading.RateLimiting package for .NET 7, but which is also compatible with netstandard2.0
and net462
, so should be usable in the ServiceBus package.
It looks like it could be a useful alternative to the very simplistic MaxConcurrentMessages
property on ServiceBusProcessorOptions
, allowing more intelligent throttling of messages coming off the bus.
Consumers could implement custom RateLimiter
types to throttle based on domain-specific parameters and constraints.
Also, a single RateLimiter
instance could be shared between multiple ServiceBusProcessor
instances running in a single process.
Internally, the code could be refactored to using ConcurrencyRateLimiter
when MaxConcurrentMessages
is used, so everything uses RateLimiter
to keep things simple.
Hi @markrendle. Thank you for your suggestion; this is an interesting idea that I think we'd like to look into further.
@JoshLove-msft, @tg-msft, @KrzysztofCwalina: I'd appreciate any thoughts that you may have.
How does a customer observe backpressure? Are they forced to catch exceptions, spin while limiter.GetAvailablePermits() <= 0
, or ...?
FWIW, I've always wanted an abstraction like https://github.com/Azure/azure-sdk/issues/3841#issuecomment-1029433201 which overlaps some of these scenarios. It'd be interesting to prototype with RateLimiter
in a pipeline policy to explore benefits/use cases across the SDK. I'd also have no problem making use of this in SB if we're already implementing our own less configurable version.
I think a sample showing how to implement a custom rate limiting policy would be great.
After further team discussion, this is not something that we are planning to add currently, as there have been no further requests nor discussion/upvotes on the issue. We'd be happy to accept a submission for a sample and collaborate on the design for one, should there be an interest in doing so. I'm going to close this out.