Publish Subscribe Messaging Model is a messaging paradigm supported by JMS (Java Message Service). It is intended to provide asynchronous message transmission between publisher and subscriber using topics. In this article, lets discuss about Publish Subscribe Messaging Model Architecture in detail.
In Publish Subscribe Messaging Model, the components are:
- Destination: Topic
- JMS Producer: Publisher
- JMS Consumer: Subscriber(s)
Publish Subscribe Messaging Model Architecture
In Publish Subscribe Messaging Model, JMS Publisher and JMS Subscriber will be configured to a Topic. JMS Publisher will create messages and publish those messages in Topics. Different JMS Subscribers will subscribe to the Topics of their interest and consume all the messages that are published in those Topics. The Publish Subscribe Messaging Model architecture is diagrammatically represented below:
Unlike Point to Point Messaging Model, the Publish Subscribe Model has a timeline dependency. The messages can be consumed by the Subscribers if the Subscriber is active at that time and only if the Subscriber is subscribed to that Topic in which the message is published.
Possible Ways to Implement Publish Subscribe Messaging Model
Publish Subscribe Messaging Model Architecture can be implemented in the following ways:
- Single publisher and several subscribers connected to a Topic
- Several publishers and single subscriber connected to a Topic
- Several publishers and several subscribers connected to a Topic
Any number of Publishers and Subscribers can be configured to a Topic as listed above, but the JMS Message published by one publisher will be consumed by all the subscribers who have subscribed to that Topic. This is because Publish Subscribe Messaging Model establishes a 1 to Many relationship between the Publisher and Subscriber.
Publish Subscribe Messaging Model Classification
Publish Subscribe Messaging Model can further be classified into two different models namely:
Persistent Messaging Model – It is also called as Durable Messaging Model. This model has the capability to store messages in the JMS Server until it is delivered to the destination.
Non-Persistent Messaging Model – It is also called as Non-Durable Messaging Model. This model does not store messages in the JMS Server.