Skip to content

Commit 86fecc7

Browse files
authored
Merge pull request #85 from rishiraj88/develop
Make update methods of Product Service transactional.
2 parents cd42a55 + a1a190e commit 86fecc7

25 files changed

Lines changed: 82 additions & 71 deletions

V1java/order/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
</parent>
1212
<groupId>om</groupId>
1313
<artifactId>order</artifactId>
14-
<version>1.0.1-SNAPSHOT</version>
14+
<version>1.0.2-SNAPSHOT</version>
1515
<name>order</name>
1616
<description>order module for order management APIs</description>
1717
<properties>
18-
<java.version>21</java.version>
18+
<java.version>24</java.version>
1919
<spring-cloud.version>2023.0.1</spring-cloud.version>
2020
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
2121
</properties>

V1java/order/src/main/java/om/order/clients/InventoryClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
* @GetExchange("/api/v1/inventory") from Spring 6 is used here, which is an alias to @HttpExchange(method = "GET")
1111
*/
1212
public interface InventoryClient {
13-
@GetExchange("/api/v1/inventory")
13+
1414
@CircuitBreaker(name = "inventory", fallbackMethod = "fallbackMethod") //The name "inventory matches the circuit breaker name in application.properties"
15+
1516
@Retry(name = "inventory")
1617
public abstract boolean isItemInStock(@RequestParam String skuCode, @RequestParam Integer quantityForQuery);
1718

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package om.order.config;
22

33
public abstract class Constants {
4-
5-
public static final String NEW_ORDER_PLACED_MSG = "An order has been created and placed.";
6-
public static final String ORDER_PLACED_QUEUE_NAME = "order-placed";
4+
public static final String NEW_ORDER_PLACED__MSG = "An order has been created and placed.";
5+
public static final String ORDER_PLACED__QUEUE_NAME = "order-placed";
76
}

V1java/order/src/main/java/om/order/config/OpenApiSpecsConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.springframework.context.annotation.Configuration;
88

99
/**
10-
* Documentation of the API of Order module (microservice) using OpenAPI Specifications (OAS)
10+
* Documentation of the API of Order module (microservice) using OpenAPI Specification (OAS)
1111
*/
1212
@Configuration
1313
public class OpenApiSpecsConfig {
@@ -23,6 +23,6 @@ public OpenAPI OrderOasApi() {
2323
> Inventory
2424
2525
Order microservice is for creating, listing, modifying and removing orders and order details. Its API has the base URI as "/api/v1/orders".
26-
""").version("v1.0.0").contact(new Contact().name("Rishi Raj").url("https://bio.link/rishiraj49de")));
26+
""").version("v1.0.0").contact(new Contact().name("Rishi Raj").url("https://www.linkedin.com/in/rishirajopenminds/")));
2727
}
2828
}

V1java/order/src/main/java/om/order/config/RestClientConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ public class RestClientConfig {
2020

2121
@Bean
2222
public InventoryClient inventoryClient(){
23-
// * RestClient from Spring 6 is used here for synchronous client with fluent API.
24-
// for non-blocking, reactive client, WebClient may be used.
23+
24+
/** RestClient from Spring 6 is used here for synchronous client with fluent API.
25+
for non-blocking, reactive client, WebClient may be used. */
2526
RestClient restClient = RestClient.builder()
2627
.baseUrl(inventoryConnectUrl)
2728
.requestFactory(getClientRequestFactory())
@@ -37,6 +38,5 @@ private ClientHttpRequestFactory getClientRequestFactory() {
3738
.withConnectTimeout(Duration.ofSeconds(3))
3839
.withReadTimeout(Duration.ofSeconds(3));
3940
return ClientHttpRequestFactories.get(httpRequestFactorySettings);
40-
4141
}
4242
}

V1java/order/src/main/java/om/order/controller/OrderController.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package om.order.controller;
22

33
import jakarta.validation.Valid;
4-
import lombok.RequiredArgsConstructor;
5-
import lombok.extern.slf4j.Slf4j;
64
import om.order.config.Constants;
75
import om.order.dto.OrderReq;
86
import om.order.dto.OrderResp;
@@ -21,20 +19,20 @@
2119

2220
//@RequiredArgsConstructor
2321
@RestController// @Slf4j
24-
//@RequestMapping(value = "/api/orders",headers = "Accept-Version=v1") // A different scheme of API versioning
22+
//@RequestMapping(value = "/api/orders",headers = "Accept-Version=v1") // A different scheme of API versioning, available to choose
2523
@RequestMapping(value = "/api/v1/orders")
2624
public class OrderController {
2725
private final OrderService orderService;
28-
public OrderController(OrderService orderService) {this.orderService = orderService;}
26+
public OrderController(OrderService orderService) {this.orderService = orderService;}
2927

30-
// @ResponseStatus(HttpStatus.CREATED): the modern way to write Controller Endpoints.
31-
// Older way is depicted in ResponseEntity<List<ProductResp>> ProductController.getAllProducts() endpoint.
28+
/** @ResponseStatus(HttpStatus.CREATED): the modern way to write Controller Endpoints.
29+
Older way is depicted in ResponseEntity<List<ProductResp>> ProductController.getAllProducts() endpoint.*/
3230
@PostMapping
3331
@ResponseStatus(HttpStatus.CREATED) // 201
3432
public String createOrder(@Valid @RequestBody OrderReq orderReq) {
3533
orderService.createOrder(orderReq);
3634
//log.debug(Constants.NEW_ORDER_PLACED_MSG);
37-
return Constants.NEW_ORDER_PLACED_MSG;
35+
return Constants.NEW_ORDER_PLACED__MSG;
3836
}
3937

4038
// getOrders()

V1java/order/src/main/java/om/order/dao/OrderRepo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
import om.order.entity.Order;
44
import org.springframework.data.jpa.repository.JpaRepository;
55

6-
public interface OrderRepo extends JpaRepository<Order,Long> {
7-
}
6+
public interface OrderRepo extends JpaRepository<Order,Long> {}

V1java/order/src/main/java/om/order/dto/OrderReq.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
import java.math.BigDecimal;
44

5-
public record OrderReq(String id, String orderNumber, String itemSkuCode,
6-
BigDecimal pricePerItemUnit,Integer quantity,UserDetails userDetails) {
7-
}
5+
public record OrderReq(String id, String orderNumber, String itemSkuCode, BigDecimal pricePerItemUnit,Integer quantity,UserDetails userDetails) {}

V1java/order/src/main/java/om/order/dto/OrderResp.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
import java.math.BigDecimal;
44

5-
public record OrderResp(String id, String orderNumber, String itemSkuCode,
6-
BigDecimal pricePerItemUnit, Integer quantity, UserDetails userDetails) {
7-
}
5+
public record OrderResp(String id, String orderNumber, String itemSkuCode, BigDecimal pricePerItemUnit, Integer quantity, UserDetails userDetails) {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package om.order.dto;
2-
public record UserDetails(String emailAddress, String name) {}
32

3+
public record UserDetails(String emailAddress, String name) {}

0 commit comments

Comments
 (0)