Differences between PointToPoint and Publish/subscribe model in JMS

Point to Point Messaging Model and Publish Subscribe Messaging Model are the two types of messaging modules/types/domains supported by Java Message Service (JMS).

These two are programming models that support asynchronous messaging between heterogeneous systems.

There are some important terms, which will help us in understanding the difference between the two messaging model types in a better way:

Let’s see the difference between these two messaging model types:

PointToPoint messaging-model (P2P) Publish/subscribe model(Pub sub)
Here the JMS Destination is queue. While JMS Destination in Pub sub is a topic.
Here the JMS producer is the sender. While JMS producer in Pub sub is a publisher.
Here the JMS consumer is receiver. While JMS consumer in Pub sub is a subscriber.
Here the message is received by only 1 JMS consumer. While in Pub sub, a message can be received by multiple JMS consumers.
Here the JMS consumer sends an acknowledgement to producer on receiving the message. While in Pub sub, the JMS consumer does not send any acknowledgement on receiving the message.
Here there exists a time dependency for the receiver to receive the message. While in Pub sub, there is no time dependency laid between producer-consumer.
This model is pull-based, which means that the receiver is responsible for requesting new messages to be sent by a sender. While this model is push-based, which means that the messages are automatically delivered to consumers without them having to request for new messages.
For ex. sending a fax/ voice message. For ex. newspapers.

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.

Article Tags :
Practice Tags :