Publish and subscribe (Pub/Sub)
When the destination is a topic, the messaging mode is said to be publish and subscribe (or Pub/Sub) where each message sent by a producer (publisher) can have zero, one, or many consumers (subscribers). IThe possible publisher-subscriber configurations in this mode are one-to-one, one-to-many, many-to-many and many-to-one.
In the Pub/Sub mode, a message is deleted as soon as it expires or as soon as it has been delivered to all its active subscribers.
There is also a special mode in which we can have a durable subscriber. With this feature, an un-expired message will be delivered to a durable subscriber as soon as it becomes active as long as it was registered as a durable subscriber before the message was published.
Unlike the PTP mode, a provider is not obligated to store a message in the Pub/Sub mode if the intended destination has no active subscriber and no registered durable subscriber.
Successful processing of a message might or might not be acknowledged in this mode. As designed, the JMS API classes are clearly grouped around messaging modes (PTP or Pub/Sub), which makes for easier programming and understanding of the model.
For example, if we know that the destination is a topic, the corresponding TopicConnectionFactory, TopicConnection, TopicSession, TopicPublisher, TopicSubscriber classes must be available to perform messaging operations for the topic destination.