11.3 使用虚拟化增强JMS消息主题
博客已搬家, 更好阅读体验, 猛戳 http://www.jack-yin.com/english/translation/activemq-in-action/1699.html
11.3 Supercharge JMS topics by going virtual
11.3 使用虚拟化增强JMS消息主题
If you want to broadcast a message to multiple consumers, then you use a JMS topic. If
you want a pool of consumers to receive messages from a destination, then you use a
JMS queue. But there’s no satisfactory way to send a message to a topic and then have
multiple consumers receiving messages on that topic the way you can with queues.
如果你想广播消息到多个消息消费者,你会使用JMS消息主题.如果你打算让多个消息消费者从
一个消息目的地接收消息,你会使用JMS消息队列.但是没有令人满意的方式用来发送消息到一个主题
并且想使用消息队列那样让多个消息消费者从这个主题接收消息.
The JMS spec requires that a durable subscriber to a topic use a unique JMS client ID
and subscriber name. Also, only one thread (a single consumer) can be active at any
time with that unique JMS client ID and subscriber name. This means that if that subscriber
dies for some reason, there will be no failover to another consumer and there’s
no ability to load balance messages across competing consumers. But using JMS queue
semantics allows the ability to fail over consumers, to load balance messages among
competing consumers, and to use ActiveMQ message groups (see chapter 12), which
allows sticky load balancing of messages to maintain message order. Furthermore, JMS
queue depths can be monitored via JMX (see chapter 14). Using virtual topics works
around these disadvantages while still retaining the benefits of JMS topics.
JMS规范要求持久化的主题订阅者使用唯一的JMS client ID和name属性.同样,同一时间只运行激活一个使用
该唯一的JMS client ID 和订阅者name的线程.(单一的消息消费者).这就是说,如果这个订阅者因为某种原因
失效后没有任何可以用来作为失效转移的消息消费者了,并且负载均衡消息也不能在处于竞争状态的消息消费者
中传递.使用JMS消息队列允许消息消费者进行失效转移,允许负载均衡消息在处于竞争状态的消息消费者之间
传递,并且允许使用消息群组(见12章)以便用粘性负载均衡消息来维持消息额次序.此外, JMS队列深度可以
通过JMX进行监控(参见第14章) .使用虚拟消息主题可以保留使用JMS主题的好处同时绕过使用主题的缺点.
.........
推荐阅读