-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientApplication.java
More file actions
53 lines (44 loc) · 1.75 KB
/
ClientApplication.java
File metadata and controls
53 lines (44 loc) · 1.75 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
46
47
48
49
50
51
52
53
package b_webflux_helloworld.client;
import b_webflux_helloworld.shared.TextDto;
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
public class ClientApplication {
public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(ClientApplication.class)
.web(WebApplicationType.NONE)
.run(args);
TimeUnit.SECONDS.sleep(10); // keep the JVM alive
}
@Bean
ApplicationRunner runner() {
return args -> {
WebClient webClient = WebClient.create("http://localhost:8080");
webClient
.get()
.uri("/restcontroller/reactor/helloworld")
.retrieve()
.bodyToFlux(String.class)
.subscribe(
System.out::println,
Throwable::printStackTrace,
() -> System.out.println("Fertig")
);
webClient
.get()
.uri("/restcontroller/reactor/helloworlddto")
.retrieve()
.bodyToMono(TextDto.class)
.subscribe(
System.out::println,
Throwable::printStackTrace,
() -> System.out.println("Fertig")
);
};
}
}