From 3e2ce28afbdeb558d8007a308ea3e6960430800c Mon Sep 17 00:00:00 2001 From: CHANDRAKANT Kumar Date: Sun, 16 Aug 2020 01:15:24 +0530 Subject: [PATCH] Incorporated the review comments on the pull request. --- spring-webflux-threads/.gitignore | 25 ------------ spring-webflux-threads/README.md | 2 +- .../com/baeldung/webflux/Application.java | 3 ++ .../java/com/baeldung/webflux/Controller.java | 40 +++++++++---------- 4 files changed, 24 insertions(+), 46 deletions(-) delete mode 100644 spring-webflux-threads/.gitignore diff --git a/spring-webflux-threads/.gitignore b/spring-webflux-threads/.gitignore deleted file mode 100644 index 82eca336e3..0000000000 --- a/spring-webflux-threads/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -/target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/build/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ \ No newline at end of file diff --git a/spring-webflux-threads/README.md b/spring-webflux-threads/README.md index 26013d73e1..279b831a6d 100644 --- a/spring-webflux-threads/README.md +++ b/spring-webflux-threads/README.md @@ -1,7 +1,7 @@ ## Spring WebFlux Concurrency This module contains articles about concurrency model in Spring WebFlux. -Please note that this assumes Mongo and Kafka to be running on the local machine on default configurations. + ### Relevant Articles: diff --git a/spring-webflux-threads/src/main/java/com/baeldung/webflux/Application.java b/spring-webflux-threads/src/main/java/com/baeldung/webflux/Application.java index 1dfa00eae0..6cba90c0f4 100644 --- a/spring-webflux-threads/src/main/java/com/baeldung/webflux/Application.java +++ b/spring-webflux-threads/src/main/java/com/baeldung/webflux/Application.java @@ -3,6 +3,9 @@ package com.baeldung.webflux; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +/** +* Please note that this assumes Mongo and Kafka to be running on the local machine on default configurations. +*/ @SpringBootApplication public class Application { diff --git a/spring-webflux-threads/src/main/java/com/baeldung/webflux/Controller.java b/spring-webflux-threads/src/main/java/com/baeldung/webflux/Controller.java index ec6d7a596b..3c7e4e41ca 100644 --- a/spring-webflux-threads/src/main/java/com/baeldung/webflux/Controller.java +++ b/spring-webflux-threads/src/main/java/com/baeldung/webflux/Controller.java @@ -53,31 +53,31 @@ public class Controller { @GetMapping("/threads/webclient") public Flux getThreadsWebClient() { WebClient.create("http://localhost:8080/index") - .get() - .retrieve() - .bodyToMono(String.class) - .subscribeOn(scheduler) - .publishOn(scheduler) - .doOnNext(s -> logger.info("Response: {}", s)) - .subscribe(); + .get() + .retrieve() + .bodyToMono(String.class) + .subscribeOn(scheduler) + .publishOn(scheduler) + .doOnNext(s -> logger.info("Response: {}", s)) + .subscribe(); return Flux.fromIterable(getThreads()); } @GetMapping("/threads/rxjava") public Observable getIndexRxJava() { Observable.fromIterable(Arrays.asList("Hello", "World")) - .map(s -> s.toUpperCase()) - .observeOn(io.reactivex.schedulers.Schedulers.trampoline()) - .doOnNext(s -> logger.info("String: {}", s)) - .subscribe(); + .map(s -> s.toUpperCase()) + .observeOn(io.reactivex.schedulers.Schedulers.trampoline()) + .doOnNext(s -> logger.info("String: {}", s)) + .subscribe(); return Observable.fromIterable(getThreads()); } @GetMapping("/threads/mongodb") public Flux getIndexMongo() { personRepository.findAll() - .doOnNext(p -> logger.info("Person: {}", p)) - .subscribe(); + .doOnNext(p -> logger.info("Person: {}", p)) + .subscribe(); return Flux.fromIterable(getThreads()); } @@ -90,9 +90,9 @@ public class Controller { SenderOptions senderOptions = SenderOptions.create(producerProps); KafkaSender sender = KafkaSender.create(senderOptions); Flux> outboundFlux = Flux.range(1, 10) - .map(i -> SenderRecord.create(new ProducerRecord<>("reactive-test", i, "Message_" + i), i)); + .map(i -> SenderRecord.create(new ProducerRecord<>("reactive-test", i, "Message_" + i), i)); sender.send(outboundFlux) - .subscribe(); + .subscribe(); Map consumerProps = new HashMap<>(); consumerProps.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092"); @@ -108,7 +108,7 @@ public class Controller { inboundFlux.subscribe(r -> { logger.info("Received message: {}", r.value()); r.receiverOffset() - .acknowledge(); + .acknowledge(); }); return Flux.fromIterable(getThreads()); } @@ -120,9 +120,9 @@ public class Controller { private List getThreads() { return Thread.getAllStackTraces() - .keySet() - .stream() - .map(t -> String.format("%-20s \t %s \t %d \t %s\n", t.getName(), t.getState(), t.getPriority(), t.isDaemon() ? "Daemon" : "Normal")) - .collect(Collectors.toList()); + .keySet() + .stream() + .map(t -> String.format("%-20s \t %s \t %d \t %s\n", t.getName(), t.getState(), t.getPriority(), t.isDaemon() ? "Daemon" : "Normal")) + .collect(Collectors.toList()); } }