diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/StockBrokerController.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/StockBrokerController.java deleted file mode 100644 index f904943a02..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/StockBrokerController.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.reactive.controller; - -import java.time.Duration; -import java.util.Date; -import java.util.Random; -import java.util.stream.Stream; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.baeldung.reactive.model.Stock; - -import reactor.core.publisher.Flux; - -@RestController -public class StockBrokerController { - - @GetMapping(produces = MediaType.TEXT_EVENT_STREAM_VALUE, value = "/getStockPrice") - public Flux getStockUpdates() { - final Flux stockFlux = Flux.fromStream(Stream.generate(() -> new Stock(new Random().nextFloat(), "WebFluxStock", new Date()))); - final Flux intervalFlux = Flux.interval(Duration.ofSeconds(1)); - return Flux.zip(stockFlux, intervalFlux) - .map(t1 -> t1.getT1()); - } -} diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Stock.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Stock.java deleted file mode 100644 index 959c8de685..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Stock.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.reactive.model; - -import java.util.Date; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@AllArgsConstructor -@Data -@NoArgsConstructor -public class Stock { - - private float price; - private String name; - private Date date; - -} diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/webclient/StockClient.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/webclient/StockClient.java deleted file mode 100644 index d86660dd90..0000000000 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/webclient/StockClient.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.reactive.webclient; - -import java.util.Collections; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.client.WebClient; - -import com.baeldung.reactive.model.Stock; - -@SpringBootApplication -public class StockClient { - - @Bean - WebClient webClient() { - return WebClient.builder() - .baseUrl("http://localhost:8080/getStockPrice") - .build(); - } - - @Bean - CommandLineRunner runner(WebClient webClient) { - return args -> { - webClient.get() - .accept(MediaType.TEXT_EVENT_STREAM) - .retrieve() - .bodyToFlux(Stock.class) - .log() - .subscribe(System.out::println); - }; - } - - public static void main(String args[]) throws InterruptedException { - new SpringApplicationBuilder(StockClient.class).properties(Collections.singletonMap("server.port", "9090")) - .run(args); - - } - -}