Skip to content

pchintar/Publisher_Subscriber_Model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Publisher-Subscriber System

A distributed messaging system where clients (publishers) send messages to a central server, which then forwards those messages only to clients that have subscribed to that topic. This decouples senders from receivers — publishers don't need to know who is listening.

Files

  • server.py - central message broker that tracks subscriptions and relays messages
  • client.py - node that can subscribe to topics and publish messages

How to Run

Open 4 terminals:

# Terminal 1 - start the server
cd publisher_subscriber_system
python3 server.py

# Terminal 2
cd publisher_subscriber_system
python3 client.py alice

# Terminal 3
cd publisher_subscriber_system
python3 client.py bob

# Terminal 4
cd publisher_subscriber_system
python3 client.py charlie

Commands

Inside any client:

  • sub TOPIC - subscribe to a topic
  • pub TOPIC MESSAGE - publish a message to a topic
  • quit - exit

Example

alice> sub weather
bob> sub weather
alice> pub weather "sunny today"

Bob receives the message. Charlie (not subscribed to weather) does not.

Requirements Met

  • Server listens for connections
  • Clients subscribe to topics
  • Clients publish messages
  • Server relays only to current subscribers
  • At least 4 nodes tested
  • No cloud storage, no data persistence on server

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages