Spring中JMS主题监听器中的并发值

时间:2013-05-07 11:36:17

标签: spring jms spring-jms

我知道Spring,但我是JMS的新手并开始阅读Spring JMS。在Spring JMS doc Spring doc中,我阅读了以下内容

The number of concurrent sessions/consumers to start for each listener.
Can either be a simple number indicating the maximum number (e.g. "5") 
or a range indicating the lower as well as the upper limit (e.g. "3-5").  
Note that a specified minimum is just a hint and might be ignored at 
runtime. Default is 1; keep concurrency limited to 1 in case of a topic 
listener or if queue ordering is important; consider raising it for 
general queues.

只是想了解为什么在主题监听器的情况下并发性限于 1 ?如果我增加它,说10而不是1,会发生什么?

1 个答案:

答案 0 :(得分:2)

每个订阅者都会收到发布到Topic的每封邮件的副本。建立多个消费者根本没有意义,因为你的所有应用程序都会在不同的线程中接收相同的消息10次。

Queue的情况下,队列上的消息将分布在10个线程中,因此可以同时处理。这确实是一种非常常见的情况 - 负载平衡。

相关问题