Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyZeng committed Nov 23, 2022
1 parent 1075cd5 commit 2992667
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
1 change: 0 additions & 1 deletion skeleton-user-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
*
Expand All @@ -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
Expand All @@ -35,10 +35,17 @@ public String getContextUserId() {

@Override
public List<String> getProviderData() {
Mono<List> listMono = webClient.get().uri("http://sc-data-service/getProviderData").retrieve().bodyToMono(List.class);
return listMono.
List<String> result = webClient.getForObject("http://sc-data-service/getProviderData", List.class);
return result;
try {
Mono<List<String>> listMono = webClient.get().uri("http://sc-data-service/getProviderData").retrieve().bodyToFlux(String.class).collectList();

List<String> 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<String> getProviderData() {
Expand Down

0 comments on commit 2992667

Please sign in to comment.