Real-time stock/news ticker notifications built with a custom Publish/Subscribe architecture in Java using TCP sockets — no Kafka/RabbitMQ.
- Start Master Node
- Start Secondary Node
- Start Subscribers
- Watch live topic notifications stream in real-time 🚀
- Topic-based subscriptions (e.g., Economic Reports, Sector Performance, Inflation)
- Master–Secondary coordination for routing + registration
- Multiple subscribers receive real-time updates based on topics
- Lightweight TCP protocol (simple message/command handling)
- Optional Docker + docker-compose setup for quick runs
Publisher/News Generator
|
v
Secondary Node (5041) <----> Master Node (5040)
|
-----------------
| | |
Sub1 Sub2 Sub3
(topic filters + real-time updates)
(pic filters + real-time updates)
- Accepts registration from nodes/subscribers
- Maintains subscriber ↔ topic mappings
- Routes updates to the correct recipients
- Connects to Master for coordination
- Accepts subscriber connections
- Forwards/relays topic updates to subscribers
- Register and subscribe to topics
- Receive real-time notifications when updates are published
master_node/→ Master server (server1.java)secondary_node/→ Secondary server (server2.java)subscriber_1/,subscriber_2/,subscriber_3/→ Subscriber clientsFront end/→ Optional simple UI assetsdocker-compose.yml→ Multi-container orchestrationDockerfile→ Base container setup
Open 4 terminals and run in this order.
cd master_node
javac server1.java
java server1cd ../secondary_node
javac server2.java
java server2 secondary_nodecd ../subscriber_1
javac subscriber1.java
java subscriber1 subscriber_1Repeat similarly for subscriber_2 and subscriber_3.
docker-compose up --build- Subscriber connects and registers (e.g.,
subscriber_1) - Subscriber subscribes to one or more topics
- Nodes publish stock/news updates
- Subscriber receives real-time messages for subscribed topics
- Java (17+)
- TCP Socket Programming
- Distributed Systems (Pub/Sub from scratch)
- Docker / Docker Compose (optional)
Make sure no .class files are tracked in GitHub:
git ls-files | grep "\.class$"If it prints anything, remove them from tracking and push cleanly.
- Heartbeats + retry logic for fault tolerance
- Message serialization (JSON / Protobuf)
- Topic persistence + replay
- Monitoring metrics (latency, throughput)