diff --git a/skeleton-user-service/pom.xml b/skeleton-user-service/pom.xml index 4bde1d8..1afe909 100644 --- a/skeleton-user-service/pom.xml +++ b/skeleton-user-service/pom.xml @@ -21,7 +21,6 @@ org.springframework.boot spring-boot-starter-webflux - org.springframework.cloud spring-cloud-starter-openfeign diff --git a/skeleton-user-service/src/main/java/git/snippets/skeleton/user/service/impl/UserService.java b/skeleton-user-service/src/main/java/git/snippets/skeleton/user/service/impl/UserService.java index ba75ba1..1a982bd 100644 --- a/skeleton-user-service/src/main/java/git/snippets/skeleton/user/service/impl/UserService.java +++ b/skeleton-user-service/src/main/java/git/snippets/skeleton/user/service/impl/UserService.java @@ -3,11 +3,11 @@ import git.snippets.skeleton.user.service.IUserService; import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import java.util.List; +import java.util.concurrent.ExecutionException; /** * @@ -17,8 +17,8 @@ public class UserService implements IUserService { private final WebClient webClient; - public UserService(WebClient webClient) { - this.webClient = webClient; + public UserService() { + this.webClient = WebClient.builder().build(); } @Override @@ -35,10 +35,17 @@ public String getContextUserId() { @Override public List getProviderData() { - Mono listMono = webClient.get().uri("http://sc-data-service/getProviderData").retrieve().bodyToMono(List.class); - return listMono. - List result = webClient.getForObject("http://sc-data-service/getProviderData", List.class); - return result; + try { + Mono> listMono = webClient.get().uri("http://sc-data-service/getProviderData").retrieve().bodyToFlux(String.class).collectList(); + + List strings = listMono.toFuture().get(); + System.out.println(strings); + return strings; + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (ExecutionException e) { + throw new RuntimeException(e); + } } // @Override // public List getProviderData() {