为什么SimpleJmsListenerContainerFactory不提供并发配置?

时间:2018-05-28 06:47:51

标签: spring spring-jms

我们可以看到SimpleMessageListenerContainer具有名为concurrentConsumers的属性,但SimpleJmsListenerContainerFactory不支持配置它。根本原因是什么?不建议对SimpleMessageListenerContainer使用并发性?

1 个答案:

答案 0 :(得分:0)

@JmsListener注释上设置并发:

/**
 * The concurrency limits for the listener, if any. Overrides the value defined
 * by the container factory used to create the listener container.
 * <p>The concurrency limits can be a "lower-upper" String &mdash; for example,
 * "5-10" &mdash; or a simple upper limit String &mdash; for example, "10", in
 * which case the lower limit will be 1.
 * <p>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.
 */
String concurrency() default "";

看起来Javadocs错了,不过

Overrides the value defined
 * by the container factory used to create the listener container.