File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
java/org/squidmin/java/spring/reactive/service Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 1
1
package org .squidmin .java .spring .reactive .service ;
2
2
3
+ import org .springframework .beans .factory .annotation .Value ;
3
4
import org .springframework .core .ParameterizedTypeReference ;
4
5
import org .springframework .stereotype .Service ;
5
6
import org .springframework .web .reactive .function .client .WebClient ;
12
13
@ Service
13
14
public class RecommendationServiceImpl implements RecommendationService {
14
15
16
+ private final String baseUrl ;
15
17
private final WebClient webClient ;
16
18
17
- public RecommendationServiceImpl (WebClient webClient ) {
19
+ public RecommendationServiceImpl (@ Value ("${product-recommendations.base-url}" ) String baseUrl , WebClient webClient ) {
20
+ this .baseUrl = baseUrl ;
18
21
this .webClient = webClient ;
19
22
}
20
23
21
24
@ Override
22
25
public Flux <Product > getRecommendations (Long productId ) {
23
26
Mono <List <Product >> purchaseHistoryRecommendation = webClient
24
27
.get ()
25
- .uri ("http://localhost:8000 /products/{id}/purchaseHistory" , productId )
28
+ .uri ("http://" + baseUrl + " /products/{id}/purchaseHistory" , productId )
26
29
.retrieve ()
27
30
.bodyToMono (new ParameterizedTypeReference <List <Product >>() {
28
31
});
29
32
30
33
Mono <List <Product >> coOccurrenceRecommendation = webClient
31
34
.get ()
32
- .uri ("http://localhost:8000 /products/{id}/coOccurrence" , productId )
35
+ .uri ("http://" + baseUrl + " /products/{id}/coOccurrence" , productId )
33
36
.retrieve ()
34
37
.bodyToMono (new ParameterizedTypeReference <List <Product >>() {
35
38
});
Original file line number Diff line number Diff line change 1
1
spring :
2
2
application :
3
- name : java-spring-reactive-web-reference
3
+ name : java-spring-reactive-web-reference
4
+
5
+ product-recommendations :
6
+ base-url : localhost:8000
You can’t perform that action at this time.
0 commit comments