Created
June 20, 2020 09:20
-
-
Save likhoman/f15aa9d5493474d1f0b734f9fd43bb6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class SomeService { | |
public Mono<ServerResponse> piu(Mono<String> body) { | |
final SomeProcess someProcess = new SomeProcess(); | |
return ServerResponse | |
.ok() | |
.body( | |
BodyInserters.fromPublisher( | |
body | |
.doOnSuccess(s -> process(someProcess)) | |
.switchIfEmpty(Mono.just("empty")) | |
.flatMap(s -> Mono.just("piu hello REQUEST_DATA=" + s)), String.class)); | |
} | |
private void process(SomeProcess someProcess) { | |
int i = 900_000; | |
while (true) { | |
System.out.println(someProcess.calc(i)); | |
if (--i == 0) { | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment