1. Added an API to generate a real time stream returning numbers. 2. Added Test case to consume that API with a webTestClient. 3. Added a client to consume that API, over the network.
29 lines
735 B
Java
29 lines
735 B
Java
package com.springwebflux.sample;
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.scheduling.annotation.EnableAsync;
|
|
import org.springframework.web.reactive.function.client.WebClient;
|
|
|
|
/**
|
|
* @author ranjeetkaur
|
|
*
|
|
*/
|
|
@SpringBootApplication(scanBasePackages = "com.springwebflux.*")
|
|
@EnableAsync
|
|
public class Client {
|
|
|
|
public static void main(String[] args) throws InterruptedException {
|
|
|
|
WebClient webClient = WebClient.builder()
|
|
.baseUrl("http://localhost:8090")
|
|
.build();
|
|
|
|
webClient.get()
|
|
.uri("/v1/dice")
|
|
.retrieve()
|
|
.bodyToFlux(Integer.class)
|
|
.log();
|
|
|
|
Thread.sleep(10000);
|
|
}
|
|
} |