-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
#2673: Microservice pattern: Polling publisher #3243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
quantdevv
wants to merge
20
commits into
iluwatar:master
Choose a base branch
from
quantdevv:issue-2673
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
faf0a12
added new microservice pattern polling-publisher, created folder stru…
quantdevv c4e9276
added two service polling service & publisher service to handle two d…
quantdevv 0051d3f
polling-publisher service implementation
quantdevv a2b8743
fixed checkstyle errors
quantdevv 4988d2e
subscriber-service implementation
quantdevv bb065d3
added entry point for subscriber service & unit test-case
quantdevv 931ab84
added unit test-case for DataSourceService class
quantdevv 78f1ea9
resolved dependency & structured classes
quantdevv a7497c4
implemented Data repository, DataSource Service & added unittest-case…
quantdevv a7cc2c3
implemented subscriber microservice using kafkaConsumer
quantdevv 46abbfb
Fixed Kafka bug & added a controller to send message using API
quantdevv 1b3d933
Fixed subscriber-service & updated pom.xml
quantdevv a59362c
Fixed topic name
quantdevv 5aa46ac
added new listener for other topic
quantdevv 4eeb011
updated all README.md
quantdevv 24b87bb
added description on both application.yaml file
quantdevv 5e3c951
synced with remote branch
quantdevv 84d08f0
added scope before class definition in Test classes & removed duplica…
quantdevv 059f292
added polling-publisher module in pom.xml
quantdevv 8c50536
Merge branch 'master' into issue-2673
quantdevv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/App.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/Cart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/CartRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/InMemoryCartRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/InMemoryOrderRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
...-architecture/src/main/java/com/iluwatar/cleanarchitecture/InMemoryProductRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/Order.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/OrderController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/OrderRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/ProductRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/ShoppingCartService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
clean-architecture/src/main/java/com/iluwatar/cleanarchitecture/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
clean-architecture/src/test/java/com/iluwatar/cleanarchitecture/AppTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
clean-architecture/src/test/java/com/iluwatar/cleanarchitecture/CartControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Polling Publisher-Subscriber Microservice Pattern | ||
|
||
This project implements a **Polling Publisher-Subscriber** system using **Spring Boot** and **Apache Kafka**. It consists of two microservices: | ||
|
||
1. **Publisher Service** → Periodically polls a data source and publishes updates via Kafka. | ||
2. **Subscriber Service** → Listens to Kafka for updates and processes them. | ||
|
||
## 📌 **Project Structure** | ||
``` | ||
polling-publisher-subscriber/ | ||
│️— pom.xml (Parent POM) | ||
│️— README.md (This file) | ||
│ | ||
├── polling-service/ | ||
│ ├── src/main/java/com/iluwatar/polling/ | ||
│ ├── src/main/resources/application.yml | ||
│ ├── pom.xml | ||
│ └── README.md (Polling-specific documentation) | ||
│ | ||
├── subscriber-service/ | ||
│ ├── src/main/java/com/iluwatar/subscriber/ | ||
│ ├── src/main/resources/application.yml | ||
│ ├── pom.xml | ||
│ └── README.md (Subscriber-specific documentation) | ||
``` | ||
|
||
## 🚀 **Tech Stack** | ||
- **Spring Boot** (Microservices) | ||
- **Apache Kafka** (Messaging) | ||
- **Maven** (Build Tool) | ||
|
||
## 🛠 **Setup & Running** | ||
### 1️⃣ **Start Kafka & Zookeeper** | ||
If you don’t have Kafka installed, use Docker: | ||
```sh | ||
docker-compose up -d | ||
``` | ||
|
||
### 2️⃣ **Build the Project** | ||
```sh | ||
mvn clean install | ||
``` | ||
|
||
### 3️⃣ **Run Service** | ||
```sh | ||
mvn spring-boot:run | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@startuml | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# **Publisher(Polling)** | ||
**README.md** (Inside `polling-module/`) | ||
|
||
|
||
## Publisher Microservice | ||
|
||
This module is responsible for **polling a data source** at regular intervals and publishing updates to Kafka. | ||
|
||
## **How It Works** | ||
- Uses a **scheduler** to poll data periodically. | ||
- Sends updates to Kafka | ||
- Exposes an API to manually trigger polling. | ||
|
||
## **Project Structure** | ||
|
||
``` | ||
publisher-module/ | ||
│️— src/main/java/com/iluawatar/polling/ | ||
| ├── App.java | ||
│ ├── DataRepository.java | ||
│ ├── DataSourceService.java | ||
│ ├── KafkaProducer.java | ||
│ ├── PollingController.java | ||
│ └── PollingScheduler.java | ||
│ | ||
│️— pom.xml | ||
│️— README.md (This file) | ||
|
||
``` | ||
|
||
## 🛠 **Running the Publisher** | ||
```sh | ||
mvn spring-boot:run | ||
``` | ||
|
||
## 📝 **Endpoints** | ||
| Method | Endpoint | Description | | ||
|--------|------------------|----------------------------------| | ||
| `GET` | `/health` | check health of polling | | ||
| `POST` | `/send?message=""` | Manually trigger data publishing | | ||
|
2 changes: 2 additions & 0 deletions
2
polling-publisher/polling-service/etc/polling-service.urm.puml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@startuml | ||
@enduml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
|
||
This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). | ||
|
||
The MIT License | ||
Copyright © 2014-2022 Ilkka Seppälä | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.iluwatar</groupId> | ||
<artifactId>polling-publisher</artifactId> | ||
<version>1.26.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>polling-service</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>com.iluwatar.polling-service.App</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README.md has a specific format. See https://github.com/iluwatar/java-design-patterns/wiki/01.-How-to-contribute