Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

38. One of the simplest ways to implement a publish/subscribe system is via a centralized broker that receives published articles and distributes them to the

image text in transcribed

38. One of the simplest ways to implement a publish/subscribe system is via a centralized broker that receives published articles and distributes them to the appropriate sub- scribers. Write a multithreaded application that emulates a broker-based pub/sub sys- tem. Publisher and subscriber threads may communicate with the broker via (shared) memory. Each message should start with a length field followed by that many charac- ters. Publishers send messages to the broker where the first line of the message con- tains a hierarchical subject line separated by dots followed by one or more lines that comprise the published article. Subscribers send a message to the broker with a single line containing a hierarchical interest line separated by dots expressing the articles they are interested in. The interest line may contain the wildcard symbol "*". The broker must respond by sending all (past) articles that match the subscriber's interest. Articles in the message are separated by the line BEGIN NEW ARTICLE." The subscriber should print each message it receives along with its subscriber identity (i.e., its interest line). The subscriber should continue to receive any new articles that are posted and match its interests. Publisher and subscriber threads can be created dynamically from the terminal by typing "P" or "S" (for publisher or subscriber) followed by the hierar- chical subject/interest line. Publishers will then prompt for the article. Typing a single line containing "" will signal the end of the article. (This project can also be imple- mented using processes communicating via TCP.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions