How does a JMS Topic Subscriber in a clustered app

2019-05-27 03:22发布

问题:

Suppose I created a JMS Topic (PropertiesTopic) with one subscriber (PropertiesSubscriber). PropertiesSubscriber is running in a load balanced application server cluster as shown in the picture below.

alt text http://www.freeimagehosting.net/uploads/be28c03781.png

When a message is delivered to PropertiesTopic, do all the instances of PropertiesSubscriber running on different app servers get that message or does the message get delivered to only one PropertiesSubscriber instance running on an app server determined by the load balancer?

回答1:

JMS 2.0 introduces shared subscriptions. These allow multiple consumers (ex: on different nodes of a cluster) to share a single Topic subscription. Only one of the consumers sharing a subscription will get each message.

To designate multiple consumers as sharing a subscription, they need to use the same sharedSubscriptionName



回答2:

All the instances of PropertiesSubscriber running on different app servers WILL get that message. Even if there are multiple listeners on the same app server for the topic, all the listeners will get the message.