cserwen opened a new issue, #8302:
URL: https://github.com/apache/rocketmq/issues/8302

   ### Is Your Feature Request Related to a Problem?
   
   If we set clientRebalance as false, we can noly control consumption rate by 
following configurations:
   ```
   consumeThreadMin
   consumeThreadMax
   ```
   In some scenarios, even a single thread may exceed the consumption rate that 
the business can accept. And it is difficult to calculate how many threads 
should be set based on the consumption rate
   
   Generally, developers use `RateLimiter` to control the rate in the consumer 
listener, but this can easily lead to consume-timeouts. It is best to provide 
this function within the SDK.
   
   ### Describe the Solution You'd Like
   
   Developers can set following configurations to control consumption rate:
   ```
   enableConsumeRateLimit=true
   // 100qps/s
   consumptionRate=100
   ```
   
   ### Describe Alternatives You've Considered
   
   Use `RateLimiter` to control rate in the messageListener
   ```java
   RateLimiter rateLimiter = RateLimiter.create(100);
   consumer.registerMessageListener(new MessageListenerConcurrently() {
       @Override
       public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, 
ConsumeConcurrentlyContext context) {
           rateLimiter.acquire();
           System.out.printf("%s Receive New Messages: %s %n", 
Thread.currentThread().getName(), msgs);
           return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
       }
   });
   ```
   
   ### Additional Context
   
   
![20240617-112036](https://github.com/apache/rocketmq/assets/46882838/8849d0c1-59d3-4edf-8ed6-5a91fb9118f3)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to