|
4 | 4 | import org.slf4j.LoggerFactory;
|
5 | 5 | import org.springframework.beans.factory.annotation.Value;
|
6 | 6 | import org.springframework.stereotype.Service;
|
7 |
| -import org.springframework.web.client.RestTemplate; |
8 | 7 | import org.springframework.web.reactive.function.client.WebClient;
|
9 | 8 | import reactor.core.publisher.Mono;
|
10 | 9 |
|
|
13 | 12 | @Service
|
14 | 13 | public class CourseCompositeIntegration {
|
15 | 14 |
|
16 |
| - private static final Logger LOG = LoggerFactory.getLogger(CourseCompositeIntegration.class); |
| 15 | + private static final Logger logger = LoggerFactory.getLogger(CourseCompositeIntegration.class); |
17 | 16 |
|
18 | 17 | private final String courseServiceUrl;
|
19 | 18 | private final String reviewServiceUrl;
|
20 | 19 | private final WebClient webClient;
|
21 | 20 |
|
22 | 21 | public CourseCompositeIntegration(
|
23 |
| - @Value("${app.course-service.host}") String courseServiceHost, |
24 |
| - @Value("${app.course-service.port}") String courseServicePort, |
25 |
| - @Value("${app.review-service.host}") String reviewServiceHost, |
26 |
| - @Value("${app.review-service.port}") String reviewServicePort, |
| 22 | + @Value("${app.course-service.uri}") String courseServiceUrl, |
| 23 | + @Value("${app.review-service.uri}") String reviewServiceUrl, |
27 | 24 | WebClient.Builder webClient
|
28 | 25 | ) {
|
29 | 26 | this.webClient = webClient.build();
|
30 |
| - courseServiceUrl = "http://" + courseServiceHost + ":" + courseServicePort; |
31 |
| - reviewServiceUrl = "http://" + reviewServiceHost + ":" + reviewServicePort; |
| 27 | + this.courseServiceUrl = courseServiceUrl; |
| 28 | + this.reviewServiceUrl = reviewServiceUrl; |
32 | 29 | }
|
33 | 30 |
|
34 | 31 | public Mono<CourseAggregate> getCourseDetails(Long id) {
|
35 | 32 | String courseUrl = courseServiceUrl + "/api/courses/" + id;
|
36 | 33 | String reviewUrl = reviewServiceUrl + "/api/reviews?course=" + id;
|
| 34 | + logger.info("Course URL ===> {}", courseUrl); |
| 35 | + logger.info("Review URL ===> {}", reviewUrl); |
37 | 36 | Mono<Course> courseMono = webClient.get()
|
38 | 37 | .uri(courseUrl)
|
39 | 38 | .retrieve()
|
|
0 commit comments