-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientApplication.java
More file actions
45 lines (36 loc) · 1.5 KB
/
ClientApplication.java
File metadata and controls
45 lines (36 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package question9.client;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.web.reactive.function.client.WebClient;
import java.util.concurrent.TimeUnit;
@SpringBootApplication(scanBasePackages = "question9.client")
public class ClientApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(ClientApplication.class);
public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(ClientApplication.class)
.web(WebApplicationType.NONE)
.run(args);
TimeUnit.SECONDS.sleep(100); // keep the JVM alive
}
@Bean
ApplicationRunner runner() {
return args -> {
WebClient webClient = WebClient.create("http://localhost:8080");
webClient
.get()
.uri("/question9/slowmillionvalues")
.retrieve()
.bodyToFlux(String.class)
.subscribe(
i -> LOGGER.info("Got: {}", i),
throwable -> LOGGER.error("exception!", throwable),
() -> LOGGER.info("Done")
);
};
}
}