diff --git a/api-gateway/Dockerfile b/api-gateway/Dockerfile index 9558927..380d7a0 100644 --- a/api-gateway/Dockerfile +++ b/api-gateway/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:17 +FROM eclipse-temurin:24 ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} application.jar ENTRYPOINT ["java", "-jar", "application.jar"] \ No newline at end of file diff --git a/api-gateway/pom.xml b/api-gateway/pom.xml index b6989c7..92277fb 100644 --- a/api-gateway/pom.xml +++ b/api-gateway/pom.xml @@ -29,11 +29,27 @@ org.springframework.cloud spring-cloud-starter-circuitbreaker-reactor-resilience4j - org.springframework.boot spring-boot-starter-actuator + + io.micrometer + micrometer-observation + + + io.micrometer + micrometer-tracing-bridge-brave + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/api-gateway/src/main/java/com/aenesgur/apigateway/ApiGateway.java b/api-gateway/src/main/java/com/aenesgur/apigateway/ApiGateway.java index ed29d3a..0af270d 100644 --- a/api-gateway/src/main/java/com/aenesgur/apigateway/ApiGateway.java +++ b/api-gateway/src/main/java/com/aenesgur/apigateway/ApiGateway.java @@ -2,10 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication -@EnableEurekaClient +@EnableDiscoveryClient public class ApiGateway { public static void main(String[] args) { SpringApplication.run(ApiGateway.class, args); diff --git a/discovery-server/Dockerfile b/discovery-server/Dockerfile index 9558927..380d7a0 100644 --- a/discovery-server/Dockerfile +++ b/discovery-server/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:17 +FROM eclipse-temurin:24 ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} application.jar ENTRYPOINT ["java", "-jar", "application.jar"] \ No newline at end of file diff --git a/discovery-server/pom.xml b/discovery-server/pom.xml index 64da2d2..e9170f7 100644 --- a/discovery-server/pom.xml +++ b/discovery-server/pom.xml @@ -21,6 +21,19 @@ org.springframework.cloud spring-cloud-starter-netflix-eureka-server + + jakarta.servlet + jakarta.servlet-api + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 02fcab6..80d4436 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,7 @@ -version: '3' services: ### Services ### discovery-server: - image: 'aenesgur/ms-ex/discovery-server-image' container_name: discovery-server build: context: ./discovery-server/ @@ -11,7 +9,6 @@ services: - "8761:8761" api-gateway: - image: 'aenesgur/ms-ex/api-gateway-image' container_name: api-gateway build: context: ./api-gateway/ @@ -26,7 +23,6 @@ services: product-service: container_name: product-service - image: 'aenesgur/ms-ex/product-service-image' build: context: ./product-service/ ports: @@ -46,7 +42,6 @@ services: - kafka order-service: - image: 'aenesgur/ms-ex/order-service-image' container_name: order-service build: context: ./order-service/ @@ -68,7 +63,6 @@ services: - kafka product-stock-service: - image: 'aenesgur/ms-ex/product-stock-service' container_name: product-stock-service build: context: ./product-stock-service/ @@ -89,7 +83,6 @@ services: - kafka send-sms-service: - image: 'aenesgur/ms-ex/send-sms-service' container_name: send-sms-service build: context: ./send-sms-service/ @@ -108,7 +101,7 @@ services: ### Dependencies ### postgres-productservice: container_name: postgres-productservice - image: postgres + image: postgres:16 environment: POSTGRES_DB: product-service POSTGRES_USER: productservice-user @@ -125,7 +118,7 @@ services: mysql-orderservice: container_name: mysql-orderservice - image: mysql + image: mysql:8 restart: unless-stopped environment: - MYSQL_ROOT_PASSWORD=123456 @@ -148,6 +141,7 @@ services: kafka: image: obsidiandynamics/kafka + platform: linux/amd64 container_name: kafka restart: "no" ports: diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..54eac0d --- /dev/null +++ b/lombok.config @@ -0,0 +1,4 @@ +config.stopBubbling = true +lombok.addLombokGeneratedAnnotation = true +lombok.anyConstructor.addConstructorProperties = true +lombok.builder.className = Builder \ No newline at end of file diff --git a/order-service/Dockerfile b/order-service/Dockerfile index 9558927..380d7a0 100644 --- a/order-service/Dockerfile +++ b/order-service/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:17 +FROM eclipse-temurin:24 ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} application.jar ENTRYPOINT ["java", "-jar", "application.jar"] \ No newline at end of file diff --git a/order-service/pom.xml b/order-service/pom.xml index 98d06bd..ce562a3 100644 --- a/order-service/pom.xml +++ b/order-service/pom.xml @@ -25,8 +25,8 @@ spring-boot-starter-data-jpa - mysql - mysql-connector-java + com.mysql + mysql-connector-j runtime @@ -49,6 +49,27 @@ org.springframework.kafka spring-kafka + + io.micrometer + micrometer-observation + + + io.micrometer + micrometer-tracing-bridge-brave + + + jakarta.validation + jakarta.validation-api + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/order-service/src/main/java/com/aenesgur/orderservice/OrderService.java b/order-service/src/main/java/com/aenesgur/orderservice/OrderService.java index 3cb10e1..fae3626 100644 --- a/order-service/src/main/java/com/aenesgur/orderservice/OrderService.java +++ b/order-service/src/main/java/com/aenesgur/orderservice/OrderService.java @@ -2,10 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication -@EnableEurekaClient +@EnableDiscoveryClient public class OrderService { public static void main(String[] args) { SpringApplication.run(OrderService.class, args); diff --git a/order-service/src/main/java/com/aenesgur/orderservice/controller/OrderController.java b/order-service/src/main/java/com/aenesgur/orderservice/controller/OrderController.java index 34870af..7a2779d 100644 --- a/order-service/src/main/java/com/aenesgur/orderservice/controller/OrderController.java +++ b/order-service/src/main/java/com/aenesgur/orderservice/controller/OrderController.java @@ -24,7 +24,8 @@ public ResponseEntity createOrder(@RequestBody OrderDto orderDto) { return new ResponseEntity("Order created succesfully.", HttpStatus.CREATED); } - public ResponseEntity productStockFallbackMethod(OrderDto orderDto, RuntimeException exception){ - return new ResponseEntity<>("Something went wrong for this operation. Please try later...", HttpStatus.SERVICE_UNAVAILABLE); + public ResponseEntity productStockFallbackMethod(OrderDto orderDto, RuntimeException exception) { + return new ResponseEntity<>("Something went wrong for this operation. Please try later...", + HttpStatus.SERVICE_UNAVAILABLE); } } diff --git a/order-service/src/main/java/com/aenesgur/orderservice/model/entity/Order.java b/order-service/src/main/java/com/aenesgur/orderservice/model/entity/Order.java index acef4e3..d583494 100644 --- a/order-service/src/main/java/com/aenesgur/orderservice/model/entity/Order.java +++ b/order-service/src/main/java/com/aenesgur/orderservice/model/entity/Order.java @@ -2,7 +2,7 @@ import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; import java.util.List; @Entity diff --git a/order-service/src/main/java/com/aenesgur/orderservice/model/entity/OrderItem.java b/order-service/src/main/java/com/aenesgur/orderservice/model/entity/OrderItem.java index 68d2efc..463490e 100644 --- a/order-service/src/main/java/com/aenesgur/orderservice/model/entity/OrderItem.java +++ b/order-service/src/main/java/com/aenesgur/orderservice/model/entity/OrderItem.java @@ -2,7 +2,7 @@ import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; import java.math.BigDecimal; @Entity diff --git a/order-service/src/main/java/com/aenesgur/orderservice/service/OrderServiceImpl.java b/order-service/src/main/java/com/aenesgur/orderservice/service/OrderServiceImpl.java index 0bbfb9d..ce53273 100644 --- a/order-service/src/main/java/com/aenesgur/orderservice/service/OrderServiceImpl.java +++ b/order-service/src/main/java/com/aenesgur/orderservice/service/OrderServiceImpl.java @@ -12,7 +12,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.reactive.function.client.WebClient; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Random; diff --git a/pom.xml b/pom.xml index 17f5302..5638d8f 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.5 + 3.2.3 com.aenesgur.microservice @@ -25,7 +25,8 @@ 17 17 - 2021.0.2 + 2023.0.0 + 1.18.30 @@ -36,6 +37,7 @@ org.projectlombok lombok + ${lombok.version} true @@ -70,6 +72,21 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + org.projectlombok + lombok + ${lombok.version} + + + + diff --git a/product-service/Dockerfile b/product-service/Dockerfile index 9558927..380d7a0 100644 --- a/product-service/Dockerfile +++ b/product-service/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:17 +FROM eclipse-temurin:24 ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} application.jar ENTRYPOINT ["java", "-jar", "application.jar"] \ No newline at end of file diff --git a/product-service/pom.xml b/product-service/pom.xml index 0907714..28a1ddb 100644 --- a/product-service/pom.xml +++ b/product-service/pom.xml @@ -20,7 +20,6 @@ org.springframework.boot spring-boot-starter-web - org.postgresql postgresql @@ -48,6 +47,22 @@ org.springframework.kafka spring-kafka + + io.micrometer + micrometer-observation + + + io.micrometer + micrometer-tracing-bridge-brave + + + jakarta.validation + jakarta.validation-api + + + org.hibernate.validator + hibernate-validator + @@ -66,6 +81,4 @@ - - \ No newline at end of file diff --git a/product-service/src/main/java/com/aenesgur/productservice/ProductService.java b/product-service/src/main/java/com/aenesgur/productservice/ProductService.java index 73d82f4..14fa862 100644 --- a/product-service/src/main/java/com/aenesgur/productservice/ProductService.java +++ b/product-service/src/main/java/com/aenesgur/productservice/ProductService.java @@ -2,10 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication -@EnableEurekaClient +@EnableDiscoveryClient public class ProductService { public static void main(String[] args) { SpringApplication.run(ProductService.class, args); diff --git a/product-service/src/main/java/com/aenesgur/productservice/event/Producer.java b/product-service/src/main/java/com/aenesgur/productservice/event/Producer.java index 164d141..e15c16f 100644 --- a/product-service/src/main/java/com/aenesgur/productservice/event/Producer.java +++ b/product-service/src/main/java/com/aenesgur/productservice/event/Producer.java @@ -1,13 +1,10 @@ package com.aenesgur.productservice.event; import com.aenesgur.productservice.model.dto.ProductEventModel; -import com.aenesgur.productservice.model.dto.ProductRequestDto; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; -import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Component; diff --git a/product-service/src/main/java/com/aenesgur/productservice/model/dto/ProductResponseDto.java b/product-service/src/main/java/com/aenesgur/productservice/model/dto/ProductResponseDto.java index b406a90..a15f2a1 100644 --- a/product-service/src/main/java/com/aenesgur/productservice/model/dto/ProductResponseDto.java +++ b/product-service/src/main/java/com/aenesgur/productservice/model/dto/ProductResponseDto.java @@ -5,9 +5,6 @@ import lombok.Data; import lombok.NoArgsConstructor; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; import java.math.BigDecimal; @Data diff --git a/product-service/src/main/java/com/aenesgur/productservice/model/entity/Product.java b/product-service/src/main/java/com/aenesgur/productservice/model/entity/Product.java index dc0377f..53ad74d 100644 --- a/product-service/src/main/java/com/aenesgur/productservice/model/entity/Product.java +++ b/product-service/src/main/java/com/aenesgur/productservice/model/entity/Product.java @@ -2,7 +2,7 @@ import lombok.*; -import javax.persistence.*; +import jakarta.persistence.*; import java.math.BigDecimal; @Entity diff --git a/product-service/src/main/java/com/aenesgur/productservice/service/ProductServiceImpl.java b/product-service/src/main/java/com/aenesgur/productservice/service/ProductServiceImpl.java index 359f342..a7e89a7 100644 --- a/product-service/src/main/java/com/aenesgur/productservice/service/ProductServiceImpl.java +++ b/product-service/src/main/java/com/aenesgur/productservice/service/ProductServiceImpl.java @@ -1,6 +1,5 @@ package com.aenesgur.productservice.service; -import com.aenesgur.productservice.event.CreateProductEvent; import com.aenesgur.productservice.event.Producer; import com.aenesgur.productservice.model.dto.ProductEventModel; import com.aenesgur.productservice.model.dto.ProductRequestDto; @@ -10,10 +9,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -29,7 +27,7 @@ public class ProductServiceImpl implements ProductService{ @Override public ProductResponseDto getById(Long id) { Optional product = productRepository.findById(id); - if (!product.isPresent()){ + if (product.isEmpty()){ return null; } return mapToDto(product.get()); diff --git a/product-stock-service/Dockerfile b/product-stock-service/Dockerfile index 9558927..380d7a0 100644 --- a/product-stock-service/Dockerfile +++ b/product-stock-service/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:17 +FROM eclipse-temurin:24 ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} application.jar ENTRYPOINT ["java", "-jar", "application.jar"] \ No newline at end of file diff --git a/product-stock-service/pom.xml b/product-stock-service/pom.xml index f5bb3e2..0fc981e 100644 --- a/product-stock-service/pom.xml +++ b/product-stock-service/pom.xml @@ -28,6 +28,27 @@ org.springframework.boot spring-boot-starter-data-mongodb + + io.micrometer + micrometer-observation + + + io.micrometer + micrometer-tracing-bridge-brave + + + org.springframework.boot + spring-boot-starter-actuator + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/product-stock-service/src/main/java/com/aenesgur/productstockservice/ProductStockService.java b/product-stock-service/src/main/java/com/aenesgur/productstockservice/ProductStockService.java index db7ca3f..dbaf8d5 100644 --- a/product-stock-service/src/main/java/com/aenesgur/productstockservice/ProductStockService.java +++ b/product-stock-service/src/main/java/com/aenesgur/productstockservice/ProductStockService.java @@ -2,10 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication -@EnableEurekaClient +@EnableDiscoveryClient public class ProductStockService { public static void main(String[] args) { SpringApplication.run(ProductStockService.class, args); diff --git a/send-sms-service/Dockerfile b/send-sms-service/Dockerfile index 9558927..380d7a0 100644 --- a/send-sms-service/Dockerfile +++ b/send-sms-service/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:17 +FROM eclipse-temurin:24 ARG JAR_FILE=target/*.jar COPY ${JAR_FILE} application.jar ENTRYPOINT ["java", "-jar", "application.jar"] \ No newline at end of file diff --git a/send-sms-service/pom.xml b/send-sms-service/pom.xml index b586124..7a3b388 100644 --- a/send-sms-service/pom.xml +++ b/send-sms-service/pom.xml @@ -24,6 +24,27 @@ org.springframework.kafka spring-kafka + + io.micrometer + micrometer-observation + + + io.micrometer + micrometer-tracing-bridge-brave + + + org.springframework.boot + spring-boot-starter-actuator + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/send-sms-service/src/main/java/com/aenesgur/sendsmsservice/SendSmsService.java b/send-sms-service/src/main/java/com/aenesgur/sendsmsservice/SendSmsService.java index 2bb2b65..d02345e 100644 --- a/send-sms-service/src/main/java/com/aenesgur/sendsmsservice/SendSmsService.java +++ b/send-sms-service/src/main/java/com/aenesgur/sendsmsservice/SendSmsService.java @@ -2,10 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.eureka.EnableEurekaClient; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @SpringBootApplication -@EnableEurekaClient +@EnableDiscoveryClient public class SendSmsService { public static void main(String[] args) { SpringApplication.run(SendSmsService.class, args);