Reactive programming
Flux
https://tech.io/playgrounds/929/reactive-programming-with-reactor-3/Flux
Return an empty Flux
1
2
3Flux<String> emptyFlux() {
return Flux.empty();
}Return a Flux that contains 2 values “foo” and “bar” without using an array or a collection
1
2
3Flux<String> fooBarFluxFromValues() {
return Flux.just("foo", "bar");
}Create a Flux from a List that contains 2 values “foo” and “bar”
1 | Flux<String> fooBarFluxFromList() { |
- Reactive Streams defines the onError signal to deal with exceptions. Note that such an event is terminal: this is the last event the Flux will produce.
Last event임을 반드시 알고 넘어가자
1 | Flux<String> errorFlux() { |
무슨 에러 인지 읽어보기 테스트1
2
3
4
Flux.error(new Exception("룰루랄라"))
.doOnError(System.out::println)
.subscribe();
Mono
Return an empty Mono
1
2
3
4
Mono<String> emptyMono() {
return Mono.empty();
}Return a Mono that contains a “foo” value
1 | Mono<String> fooMono() { |
- Create a Mono that emits an IllegalStateException
1 | Mono<String> errorMono() { |
StepVerifier
- Test에 쓸수 있어요!! nonblocking디버깅에 유용
- Use StepVerifier to check that the flux parameter emits “foo” and “bar” elements then completes successfully.
1 |
|
- Use StepVerifier to check that the flux parameter emits “foo” and “bar” elements then a RuntimeException error.
1 |
|