Starting from:
$35

$29

Homework 4 - Bulletin Board System: Pub/Sub system Solution

    1. Introduction

In this part, you are going to implement the subscription features for the BBS service. The event will be raised whenever the client creates a new post that title contains the keyword subscribed by any other client.

    2. Example Architecture using Apache Kafka

The middleware server will get a message/record from the producer when there has a new post and also notify the client(s) who have subscribed to the specified topic.

    A. BBS server is a producer, and each client is a consumer


























    B. Each client act as both a producer and a consumer

    3. Requirements

The service can serve at least 10 clients. Your server and client program must be able to handle all commands in the previous part (output results must be the same as the previous part). For some commands such as whoami, exit, logout, create-board, list-board ##<key> and list-post <board-name> ##<key>, your client program only sends the command to the server and gets the corresponding result from the server. However, there are new commands that your client program will subscribe to the new post. These commands are described as follows:

Command format
Description

Result




subscribe --board <board-name>
Subscribe the board with a keyword,
Success
Subscribe successfully
--keyword <keyword>
notify the client whenever the event be

(The notify message should
(command and arguments are in the
raised.

at least include board, title,
same line)
Note [1]: Can subscribe the same

and author)

board multiple times with different




Fail (1)
Please login first

keywords. Notify user once someone




Fail (2)
[Invalid option] usage:

creates a new post with a specified

subscribe --board <board-

board and the title contains one of the

name> --keyword

keywords

<keyword>

Note [2]: Subscribe objective (board)




Fail (3)
Already subscribed

can be nonexistent






subscribe --author <author-name>
Subscribe the author with a keyword,
Success
same as the previous one
--keyword <keyword>
notify the client whenever the event be




Fail (1)
same as the previous one




(command and arguments are in the
raised.




Fail (2)
[Invalid option] usage:




same line)


subscribe --author <author-





Both notes [1] and [2] are same as the

name> --keyword





previous one (change objective to

<keyword>





author) ↑




Fail (3)
same as the previous one








unsubscribe --board <board-name>
Unsubscribe the board from the server
Success
Unsubscribe successfully

(or middleware server) and remove all




Fail (1)
Please login first

the keywords associated with a specified








Fail (2)
You haven't subscribed

board.









<board-name>




unsubscribe --author <author-name>
Unsubscribe the author from the server
Success
Unsubscribe successfully

(or middleware server) and remove all




Fail (1)
Please login first





the keywords associated with a




Fail (2)
You haven't subscribed





specified author.

<author-name>








list-sub
List the information about the
Success
List all the subscribed info

subscribed board(s) and author(s).




Fail (1)
Please login first





    4. Scenario

Run your server first, and run your client program to connect to your server. The sample outputs of the client program are listed as follows:
Client 1

Client 2
Client 3



bash$ ./client 127.0.0.1 7777
bash$ ./client 127.0.0.1 7777
bash$ ./client 127.0.0.1 7777
********************************
********************************
********************************
** Welcome to the BBS server. **
** Welcome to the BBS server. **
** Welcome to the BBS server. **
********************************
********************************
********************************
% register Paul paul@cs.nctu.edu.tw 12345
% register Brad brad@cs.nctu.edu.tw 12345
% register Gary gary@cs.nctu.edu.tw 12345
Register successfully.
Register successfully.

Register successfully.




% login Paul 12345
% login Brad 12345

% login Gary 12345
Welcome, Paul.
Welcome, Brad.

Welcome, Gary.




% subscribe --board HW4_Board
% subscribe --author Jason --keyword hw4

--keyword Project

Subscribe successfully

Subscribe successfully







% create-board HW4_Board




Create board successfully.








% subscribe --board HW4_Board
% subscribe --author Paul --keyword HW

--keyword Project

Subscribe successfully

Already subscribed

% subscribe --author Paul --keyword post

% subscribe --author Bryant
Subscribe successfully

--keyword exam

% unsubscribe --author Brad

Subscribe successfully

You haven't subscribed Brad





% create-post HW4_Board




--title About Project --content HW4…




Create post successfully.








% *[HW4_Board] About Project – by Paul*


% list-board ##HW



Index
Name
Moderator


1
HW4_Board
Paul




% create-post HW4_Board
% unsubscribe --author Bryant

--title About HW and Exam --content
Unsubscribe successfully


blablabla




Create post successfully.










% list-sub


% *[HW4_Board] About HW and Exam –

Board: HW4_Board: Project
by Paul*




% list-sub




Author: Jason: hw4; Paul: HW, post





    5. Notes

        1. About implementation:

            ▪ There is no limitation on your implementation. You can choose whatever which framework, library, or even implement the logic by yourself, as long as it can achieve the goal of spec.

            ▪ The output message should show the information at least greater or equal to mentioned in the requirements. In addition, it not restricted in any format.

        2. About Kafka environment setup:

            ▪ Please refer to the slide in E3 – Apache Kafka Installation and Configuration.

        3. About Kafka clients:

            ▪ C/C++

                    ◦ https://github.com/edenhill/librdkafka

            ▪ Python

                    ◦ https://github.com/dpkp/kafka-python

                    ◦ https://github.com/confluentinc/confluent-kafka-python

            ▪ Node.js

                    ◦ https://github.com/Blizzard/node-rdkafka

                    ◦ https://github.com/tulios/kafkajs

                    ◦ https://github.com/SOHU-Co/kafka-node

    6. Grading Policy (100%)

                • [20%] Commands from previous parts

                • [30%] Subscribe part

                • [30%] Unsubscribe part

                • [20%] List-sub part

    7. Submission

Please upload a zip file called “hw4_{$student_id}.zip” (e.g., hw4_0516000.zip) that includes your source code. It must include at least your server source code and client source code. The submission that doesn’t follow the rule will get 20% punishment on the grade.

You will get 0 points on this project for plagiarism.

More products