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?
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
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.
来源:https://stackoverflow.com/questions/2017520/how-does-a-jms-topic-subscriber-in-a-clustered-application-server-recieve-messag