https://github.com/saitejesh12345/kafkaorderamountalertmailservice
Overall, this code represents an application that saves orders, sends order events to Kafka, consumes order events from Kafka, and sends email alerts for highest orders. It uses Spring Boot, Spring Data JPA, Kafka, and JavaMailSender for these functionalities.
https://github.com/saitejesh12345/kafkaorderamountalertmailservice
Last synced: 4 months ago
JSON representation
Overall, this code represents an application that saves orders, sends order events to Kafka, consumes order events from Kafka, and sends email alerts for highest orders. It uses Spring Boot, Spring Data JPA, Kafka, and JavaMailSender for these functionalities.
- Host: GitHub
- URL: https://github.com/saitejesh12345/kafkaorderamountalertmailservice
- Owner: saitejesh12345
- Created: 2023-12-06T05:35:10.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-06T06:00:26.000Z (over 1 year ago)
- Last Synced: 2025-01-04T08:48:07.881Z (5 months ago)
- Language: Java
- Size: 68.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# KafkaOrderAmountAlertMailService
Overall, this code represents an application that saves orders, sends order events to Kafka, consumes order events from Kafka, and sends email alerts for highest orders. It uses Spring Boot, Spring Data JPA, Kafka, and JavaMailSender for these functionalities.This code appears to be a part of an application that handles orders and alerts based on the order amount. Let me explain the code in detail:
1. **OrderController**: - This is a REST controller that handles incoming HTTP POST requests to create orders. - It uses the `OrderService` to save the order and then returns the saved order along with a status code.
2. **OrderService**: - This is an interface defining the contract for saving orders.
3. **OrderServiceImpl**: - This is the implementation of the `OrderService` interface. - It saves the order using the `OrderRepository` and sends a highest order alert using the `AlertService`.
4. **OrderRepository**: - This is a Spring Data repository interface for the `Order` entity.
5. **Order**: - This is an entity class representing an order with properties such as `id`, `productName`, and `amount`. - It is annotated with JPA annotations such as `@Entity`, `@Id`, `@GeneratedValue`, and `@Data` for automatic generation of getters, setters, and other boilerplate code.
6. **OrderEventProducer**: - This is a service responsible for sending order events to a Kafka topic named "HighestOrder" using a `KafkaTemplate`.
7. **OrderKafkaConsumer**: - This is a Kafka consumer that listens to the "HighestOrder" topic and consumes order events. - It uses the `AlertService` to check if the order amount is the highest and then logs the consumed message.
8. **AlertService**: - This service has a `thresholdAmount` property and is responsible for sending highest order alerts. - It uses the `JavaMailSender` to send email alerts and the `OrderEventProducer` to send order events to Kafka if the order amount exceeds the threshold.
9. **MailConfig**: - This class configures the `JavaMailSender` properties for sending email alerts.
10. **KafkaConsumerConfig**: - This class configures the Kafka consumer properties and deserializers for consuming order events from the "HighestOrder" topic.Installation
------------------------------------------------------------------------
dependency: Java 8
download: https://kafka.apache.org/downloads Scala - 2.13 (tgz)Extract it to drive:/kafka
create folder drive:/kafka/data/zookeeper //state maintanence
create folder drive:/kafka/data/kafka //kafka server logsopen drive:/kafka/config/zookeeper.properties
set the below prop:
dataDir=drive:/kafka/data/zookeeperopen drive:/kafka/config/server.properties
set the below prop:
log.dirs=drive:/kafka/data/kafkaINSTALLATION IS DONE
Start Up
------------------------------------------------------------------------Start ZooKeeper
drive:\kafka\bin\windows>zookeeper-server-start.bat ../../config/zookeeper.propertiesStart Kafka
drive:\kafka\bin\windows>kafka-server-start.bat ../../config/server.properties
**First Start Zookeeper server then start kafka Server after Running Both the Server then Start SpringBoot Application****Postman**
**Alertmail**