https://github.com/alpha74/pub-sub-queue_javaspringboot
Code for Pub-Sub queue implementation using Java Spring Boot.
https://github.com/alpha74/pub-sub-queue_javaspringboot
Last synced: 10 months ago
JSON representation
Code for Pub-Sub queue implementation using Java Spring Boot.
- Host: GitHub
- URL: https://github.com/alpha74/pub-sub-queue_javaspringboot
- Owner: alpha74
- Created: 2024-09-06T15:41:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-06T15:48:44.000Z (over 1 year ago)
- Last Synced: 2025-01-16T04:41:13.039Z (12 months ago)
- Language: Java
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

## Pub-Sub Queue
### Requirements
1. API to expose topics
- print list of all topics
2. API for publisher to push message against a topic
3. API to subscribe and unsubscribe from a topic
4. API for subscriber to consume from a topic
5. Maintain the state of consumption of each message in each topic for each consumer
6. Maintain order of message consumption for each consumer
### Entities
#### Message
- String data
- String publisherId
#### Subscriber
- Reads from a Topic
- Can subscribe to single topic
- name
- topic -> Topic or null
- consume()
#### Publisher
- publishes to a Topic
- can publish to multiple topics
- name
- publish(Message, Topic)
#### Topic
- name
- List of Messages
- Map of Subscribers vs offset
### Services
#### TopicService
- createTopic(name)
- getTopics()
- deleteTopic()
- Fail if messages are pending to be consumed
- isPresent() -> checks if topic is present or not
- getTopicByName()
#### BrokerService
- addSubscriber(Subscriber, Topic)
- removeSubscriber(Subscriber)
- publishMessage(Message, Publisher, Topic)
- consumeMessage(Subscriber)
--------
#### Improvements which were suggested:
1. Create separate Services for Publisher and Subscriber
2. This implementation is Push and Pull, think of Publish and Subscribe