使用 @JmsListener 配置限制消息速率。

huangapple go评论59阅读模式
英文:

Configure @JmsListener to limit rate of messages

问题

我已经实现了@JmsListener来监听来自生产者的消息。

应用程序 <- 消费者 <- 生产者

因此,如上所示,消费者正在从生产者那里消费消息,并调用应用程序(APP)来处理这些消息,在这种情况下,应用程序运行缓慢,我们希望限制我们从队列中消费消息的速率 (消费者 <- 生产者)

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

寻找限制生产者消息速率的方法,可以通过限制订阅或者与并发有关的方式来实现,但是在@JmsListener注解中并没有找到相关支持。

英文:

I have implemented @JmsListener to listen the messages from Producer.

APP &lt;- Consumer &lt;- Producer

So, as shown above Consumer is consuming messages from producer and calling application(APP) to process those messages, in this case application is slow and we wanted to limit the rate of messages we are consuming from queue (Consumer &lt;- Producer)

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

Finding the way to limit the rate of messages from Producer, It can be done by limiting subscription or something with concurrency but not find any support @JmsListener annotation

答案1

得分: 1

有一个@JmsListener并发选项:

> 监听器的并发限制,如果有的话。会覆盖用于创建监听器容器的容器工厂定义的值。
>
> 并发限制可以是一个“较低-较高”的字符串 — 例如,“5-10” — 或者是一个简单的上限字符串 — 例如,“10”,在这种情况下,下限将为1。
>
> 请注意,底层容器可能支持或不支持所有功能。例如,它可能无法进行扩展,这种情况下只使用上限。

英文:

There is a @JmsListener concurrency option:

> 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.

huangapple
  • 本文由 发表于 2020年10月27日 18:11:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/64552187.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定