In software architecture, publish–subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers, but instead characterize published messages into classes without knowledge of which subscribers, if any, there may be. Similarly, subscribers express interest in one or more classes and only receive messages that are of interest, without knowledge of which publishers, if any, there are.
2. INTENT
In Software Architecture, PUBLISH-
SUBSCRIBE Pattern is a message
pattern – a network oriented
architectural pattern – which
describes how two different parts of a
message passing system connect and
communicate with each other.
MORE ON IT FURTHER..
3. MOTIVATION/PROBLEM
How can an application in an
integration architecture only send
messages to the applications that are
interested in receiving the messages
without knowing the identities of the
receivers?
7. SO,
Q: WHAT DOES A PUBLISHER
DO?
A: Easy, it publishes messages to
the communication
infrastructure.
8.
9. OKAY. SO,
Q: WHAT DOES A SUBSRIBER
DO?
A: Easy, it subscribes to a
category of messages.
10.
11. HMMM. SO,
Q: WHAT IS A COMMUNICATION
INFRASTRUCTURE?
A:
• It receives messages from
publishers.
• It maintains the subscribers'
subscriptions to transport the
messages to the respective
subscribers.
12. APPLICABILITY
In the pub/sub model, subscribers typically receive only a subset of the total
messages published. The process of selecting messages for reception and
processing is called filtering.
There are two common forms of filtering: topic-based and content-based.
In a topic-based system, messages are published to "topics" or named logical
channels. Subscribers in a topic-based system will receive all messages published
to the topics to which they subscribe, and all subscribers to a topic will receive
the same messages. The publisher is responsible for defining the classes of
messages to which subscribers can subscribe.
In a content-based system, messages are only delivered to a subscriber if the
attributes or content of those messages match constraints defined by the
subscriber. The subscriber is responsible for classifying the messages.
Some systems support a hybrid of the two; publishers post messages to a topic while
subscribers register content-based subscriptions to one or more topics.
13. CONSEQUENCES
Benefits
• Loose coupling. The publisher is not aware of the number of subscribers, of the
identities of the subscribers, or of the message types that the subscribers are
subscribed to.
• Improved security. The communication infrastructure transports the published
messages only to the applications that are subscribed to the corresponding topic.
Specific applications can exchange messages directly, excluding other applications
from the message exchange.
• Improved testability. Topics usually reduce the number of messages that are required
for testing.
Liabilities
• Increased complexity. Publish/Subscribe requires you to address the following:
You have to design a message classification scheme for topic implementation.
You have to implement the subscription mechanism.
You have to modify the publisher and the subscribers.
• Increased maintenance effort. Managing topics requires maintenance work.
Organizations that maintain many topics usually have formal procedures for their use.
• Decreased performance. Subscription management adds overhead. This overhead
increases the latency of message exchange, and this latency decreases performance.