What is now known as the Publish-Subscribe (or affectionately PubSub) software design pattern was originally proposed by Birman and Joseph in a paper entitled Exploiting Virtual Synchrony in Distributed Systems, presented to the 11th Association for Computing Machinery (ACM) symposium on operating system principles. To boil down a rather complex algorithm into simple terms, a publisher is a software class that sends a message before or after an event of significance takes place. A common example of such an event would be a database modification. A subscriber is a software class that listens to messages produced by its associated publisher. The subscriber examines the message, and may or may not take action, at its own determination. In our example scenario, we create a publisher class that sends a message to subscribers when a loan payment is received. The subscriber performs the secondary update on the relevant borrower document.
The publish/subscribe design pattern
Beginning with MongoDB...