我想知道JMS队列和JMS主题之间的区别是什么。
ActiveMQ页面说
Topics
In JMS a Topic implements publish and subscribe semantics. When you publish a message it goes to all the subscribers who are
interested - so zero to many subscribers will receive a copy of the
message. Only subscribers who had an active subscription at the time
the broker receives the message will get a copy of the message.
Queues
A JMS Queue implements load balancer semantics. A single message will be received by exactly one consumer. If there are no
consumers available at the time the message is sent it will be kept
until a consumer is available that can process the message. If a
consumer receives a message and does not acknowledge it before closing
then the message will be redelivered to another consumer. A queue can
have many consumers with messages load balanced across the available
consumers.
我想要有一个“东西”,它将以与ActiveMQ代理接收消息时相同的顺序将消息的副本发送到每个订阅者。
任何想法吗?
A JMS topic is the type of destination in a 1-to-many model of distribution.
The same published message is received by all consuming subscribers. You can also call this the 'broadcast' model. You can think of a topic as the equivalent of a Subject in an Observer design pattern for distributed computing. Some JMS providers efficiently choose to implement this as UDP instead of TCP. For topic's the message delivery is 'fire-and-forget' - if no one listens, the message just disappears. If that's not what you want, you can use 'durable subscriptions'.
JMS队列是1对1的消息目的地。消息仅由一个消费接收者接收(请注意:始终使用订阅者作为“主题客户端”而使用接收者作为“队列客户端”以避免混淆)。发送到队列的消息存储在磁盘或内存中,直到有人拾取或过期。因此,队列(和持久订阅)需要一些活动存储管理,您需要考虑缓慢的消费者。
在大多数环境中,我认为主题是更好的选择,因为您总是可以添加额外的组件,而不必更改架构。添加的组件可以是监控、日志记录、分析等。
在项目开始时,你永远不知道1年、5年、10年后的需求是什么。改变是不可避免的,拥抱它吧:-)
A JMS topic is the type of destination in a 1-to-many model of distribution.
The same published message is received by all consuming subscribers. You can also call this the 'broadcast' model. You can think of a topic as the equivalent of a Subject in an Observer design pattern for distributed computing. Some JMS providers efficiently choose to implement this as UDP instead of TCP. For topic's the message delivery is 'fire-and-forget' - if no one listens, the message just disappears. If that's not what you want, you can use 'durable subscriptions'.
JMS队列是1对1的消息目的地。消息仅由一个消费接收者接收(请注意:始终使用订阅者作为“主题客户端”而使用接收者作为“队列客户端”以避免混淆)。发送到队列的消息存储在磁盘或内存中,直到有人拾取或过期。因此,队列(和持久订阅)需要一些活动存储管理,您需要考虑缓慢的消费者。
在大多数环境中,我认为主题是更好的选择,因为您总是可以添加额外的组件,而不必更改架构。添加的组件可以是监控、日志记录、分析等。
在项目开始时,你永远不知道1年、5年、10年后的需求是什么。改变是不可避免的,拥抱它吧:-)