So guys, now let us try to understand another example regarding how notification chain works.
Let us suppose that you have a software system and that software system is divided into different different
modules or independent components.
One of the component is publisher because it is in charge of some data source, right?
So for illustration purpose, let us say that publisher is a module of a software component, which
is the owner of some data source, let us say routing table, for example.
Right.
So any component which is in charge of some data source and in that data, some other component shows
interest, then the component which is owning that data source is called a publisher.
Whereas the rest of the components of the software systems, which shows interest in the data source
owned by the publisher are called subscribers.
So let us say that our software system has more number of independent components which are running independently.
Let us say application one, application to application three and application four.
Right.
When I say components, you can assume that these subscribers and publishers are independent threads
running in the context of the same process.
Though, to implement a publisher subscriber model.
It is not a constraint.
The different components could be different software systems running in the context of different processes
or running on different machines all together for the sake of simplicity to understand notification
chains.
We have taken an example in which the publisher and the subscribers are different components of the
same software system.
Right?
Now let us say that the application one is interested in notification from the publisher related to
the entry.
122 .1.1.1 slash 32.
Right.
So in order to express interest the application, one will send subscription request to the publisher.
Right?
In this subscription request, the subscriber application one will convey the publisher that Hey publisher,
I'm interested in the notification related to this entry.
And whenever there is a change that is update, delete or modification of any type in this entry, please
notify me using this function FA1.
Right.
So the moment the publisher get this subscription request, it will create an entry in its notification
chain.
In this entry, it will store the key in which the subscriber is interested, and it will also save
the callback function of the subscriber.
Right.
Similarly, let us suppose that the application two also sends subscription request to the publisher
and the application two is interested in the entry for 122.1 .1.2 32.
Right.
There is a typo here.
Let us suppose that in this routing table this is entry number three and this is entry number four,
right?
So now let us suppose that Application three has expressed its interest in the entry number 122 .1.1.3.
Right.
And therefore it also do the registration with the publisher by sending the subscription request.
Right?
Application for is somewhat different.
It is interested in all the entries of this routing table.
That is, whenever there is a change or modification of any type in any entry of the routing table,
subscriber application for is interested in notification, right?
So it will again send a subscription message to the publisher.
But in this subscription message, the application for will not specify any key right?
Not specifying any key works as a wild card.
So throughout this process you can see that subscribers have registered their callbacks with the publishers
against the entries which they are interested in.
Right?
So this link list is called notification chain, which is maintained by the publisher, right?
The publisher can add or delete nodes from this notification chain depending on the subscription or
unsubscription request received from the subscribers.
When publisher updates the entry in its routing table, the publisher simply iterates over the notification
chain and invoke callbacks of subscribers matching the entry.
Right?
So, for example, let us suppose that publisher executes some logic due to which the publisher updates
its routing table entry.
Say 122 .1.1.3 and instead of 101, let us say it starts at zero.
It simply means that this particular entry has been updated by publisher.
So whenever the publisher updates any entry in its data source, it walks over its notification chain
and find the matching entry, which is updated.
Right.
And now Publisher finds that there is a callback registered, so it simply invokes this callback functions
and in this callback function it will pass the information regarding which entry is updated along with
the rest of the information of the entry.
Right.
So it simply means that publisher will tell the application that, hey, application three, the entry
number 122.1 .1.3 has been updated and the new updated values is the remaining attributes of this entry.
Right?
Similarly, in this example, the publisher also sees that there is no key at all in this notification
chain entry.
Right?
It simply means that it do not have to worry anything about this key.
And it doesn't matter that which entry in the routing table is updated, the publisher simply invoke
the callback for four, meaning that it is notifying the application four about the update in its routing
table.
Right.
So subscribers who have registered without key will be notified for all the updates.
All updates means whenever any entry in the routing table changes the.
The subscriber who have registered with the publisher with the wild card key will be notified.
Right.
So this is one example regarding how notification chain works, and this is a very simplified example.
So now you should understand that how notification chains grow or shrink depending on subscription or
unsubscription requests coming from the subscribers.
So notification chain is a kind of chain or link list or a database which is maintained by the publisher,
right?
And for each data source, the publisher maintains a separate notification chain, right?
If a publisher has multiple data sources, the publisher will maintain absolutely separate notification
chains for each of its data sources.
Right.