英文:
How consumer QueueChannel with some rate?
问题
这里是一个示例,展示了如何填充和处理队列。但是如何按速率处理消息?比如每秒处理N
条消息?
更新
这里的“处理”是指“出队”。例如,如何每秒出队N条消息?
英文:
Here is example how fill and process queue. But how process message with rate? Like process N
messages per second?
UPDATE
Here by "porcess": I meant "dequeue". E.g. how to dequeue N messages per second?
答案1
得分: 0
你可以像我之前提到的那样编写一个循环,配合某种速率控制(例如,通过Thread.sleep作为最基本的方法)。
你还可以尝试使用@Scheduled注解。
这里有一个示例方法,它将每秒调用100次:
@Scheduled(fixedRate = 10)
public void dequeue() {
//queue.poll(..)
}
英文:
You can wrote a loop as I mentioned earlier with some kind of rate control (e.g, via Thread.sleep as the most rudimentary).
You can also try to use @Scheduled annotation.
Here is the example of a method that will be invoked 100 times per second
@Scheduled(fixedRate = 10)
public void dequeue() {
//queue.poll(..)
}
专注分享java语言的经验与见解,让所有开发者获益!
评论