Merge branch 'master' of https://github.com/micropatel/tutorials
Removed unwanted class
This commit is contained in:
commit
1c03ee9c42
@ -1,29 +0,0 @@
|
|||||||
package com.baeldung.reactive;
|
|
||||||
|
|
||||||
import org.springframework.boot.CommandLineRunner;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public class ReactiveEventClient implements CommandLineRunner {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.setProperty("server.port","8090");
|
|
||||||
SpringApplication.run(ReactiveEventClient.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(String... args) throws Exception {
|
|
||||||
WebClient webclient = WebClient.builder()
|
|
||||||
.defaultHeader(HttpHeaders.ACCEPT, MediaType.TEXT_EVENT_STREAM_VALUE)
|
|
||||||
.baseUrl("http://localhost:8080/events")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
webclient.get().uri("/stream/").header(HttpHeaders.CONTENT_TYPE,MediaType.TEXT_HTML.toString())
|
|
||||||
.retrieve().bodyToFlux(String.class)
|
|
||||||
.subscribe(System.out::println);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package com.baeldung.reactive.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import reactor.core.publisher.Flux;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/events")
|
|
||||||
public class ReactiveEventServer {
|
|
||||||
|
|
||||||
@GetMapping(path = "/stream/" , produces=MediaType.TEXT_EVENT_STREAM_VALUE)
|
|
||||||
public Flux<String> eventStream() {
|
|
||||||
return Flux.interval(Duration.ofSeconds(1)).map(tick -> {return "Event:" + tick;});
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user