配置@JmsListener 限制消息速率

Configure @JmsListener to limit rate of messages

我已经实施 @JmsListener 来监听来自 Producer 的消息。

APP <- Consumer <- Producer

因此,如上所示,Consumer 正在使用来自生产者的消息并调用应用程序 (APP) 来处理这些消息,在这种情况下,应用程序速度很慢,我们想限制我们正在使用的消息的速率队列 (Consumer <- Producer)

 @JmsListener(
       containerFactory = XXX destination = XXX)   public void receive(Message message) throws JMSException {
       }

想办法限制Producer发送消息的速率,可以通过限制订阅什么的并发来实现,但是没有找到支持@JmsListener注解

有一个@JmsListener concurrency选项:

The concurrency limits for the listener, if any. Overrides the value defined by the container factory used to create the listener container.

The concurrency limits can be a "lower-upper" String — for example, "5-10" — or a simple upper limit String — for example, "10", in which case the lower limit will be 1.

Note that the underlying container may or may not support all features. For instance, it may not be able to scale, in which case only the upper limit is used.