The whole scenario is depicted in Figure. We use Publish-Subscribe messaging between the StockServer and the Subscriber . As mentioned earlier, Publish-Subscribe messaging is used when multiple clients need to receive the same set of messages. The central concept in this type of messaging is the Topic, which is used to represent the Destination. Topics are created by an administrator and registered with a JNDI context.
Clients can send messages to a Topic and receive messages from a Topic.
Topics are expected to have multiple subscribers listening for messages. A client uses JNDI to locate a TopicConnectionFactory . The TopicConnectionFactory class implements the ConnectionFactory interface and is used to create TopicConnection objects. The TopicConnection class implements the Connection interface, and is used to create TopicSessions. TopicSessions are used to create the Publishers and Subscribers for a Topic.