Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PointToPoint vs Publish/subscribe model in JMS?

Tags:

I am new to JMS. I have started with "hello world" where I am publishing the message from java application on Topic and listening it from client (node.js Javascript). I have gone through this wikipedia entry, but I have some questions based on my previous theoretical understanding.

As per my understanding, point-to-point is the queue implementation where there can be at most one consumer subscribed on queue and can be consumed by that only. Neither producer nor the consumer knows about each other. Queue is hosted on message brokers in my case Apache ActiveMQ. Queue can be created by producer before publishing the message (or it can be created from console in advance).

In case of publish/subscribe model, it's almost same as point-to-point except the fact we use Topic instead of queue. In this model there can be more than more consumer on the topic. Once the message is published, all the subscribers will be notified. Now if any of the subscriber, send the acknowledgment for the published message, message will taken as consumed and it will no longer be available for new subscriber?

like image 932
M Sach Avatar asked Nov 14 '12 11:11

M Sach


1 Answers

Point to Point means message(s) is sent from one application(producer or sender) to another application(consumer/receiver) via a queue. There can be more than one consumer listening on a queue but only one of them will be get the message. Hence it is Point to Point or One to One.

On the other hand Publish/Subscribe is another messaging model where a message(or publication as it is commonly called) is sent to multiple consumers(or subscribers) through a topic. The topic is the link between publisher and subscriber. The subscribers may or may not acknowledge the published message. Implementations like JMS acknowledge the message the messaging providers but not the sender of the message. Publications will be received by all subscribers, durable and non-durable. Any new subscribers on the same topic will not get the publication unless it is a Retained publication.

I would recommend you to read further on,

  1. Durable subscription
  2. Non-durable subscription
  3. Retained publication
like image 134
Shashi Avatar answered Sep 24 '22 12:09

Shashi