Created
February 15, 2022 07:02
-
-
Save ashikuzzaman-ar/8ce42a2493e179af48d94860be68f9bc to your computer and use it in GitHub Desktop.
What if you have no choice to call some blocking codebase from a legacy library or some legacy system. This is a way arround for the problem. Though this is not reactive but at least it's non blocking.
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
@Test | |
void callingBlockingCodeInReactiveStreams() { | |
Mono.fromCallable(() -> { | |
// Your blocking code here | |
return new Object(); | |
}).subscribeOn(Schedulers.boundedElastic()); | |
Flux.fromIterable(Stream.of(1, 2, 3, 4, 5).map(i -> { | |
// Your blocking code here | |
return new Object(); | |
}).toList()) | |
.subscribeOn(Schedulers.boundedElastic()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment