3

我知道 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,会发生什么?

4

1 回答 1

3

每个订阅者都会收到发布到Topic. 设置多个消费者根本没有意义,因为您的应用程序要做的就是在不同的线程中接收相同的消息 10 次。

在 a 的情况下Queue,队列上的消息将分布在 10 个线程中,因此是同时处理的。这确实是一个很常见的场景——负载均衡。

于 2013-05-08T18:50:34.277 回答