https://github.com/daggerok/avoiding-reactor-meltdown
Handling blocking calls in Reactor applications (correctly)
https://github.com/daggerok/avoiding-reactor-meltdown
block-hound blockhound blocking reactor reactor-blockhound reactor-debug-agent reactor-tools spring-webflux webflux
Last synced: 10 months ago
JSON representation
Handling blocking calls in Reactor applications (correctly)
- Host: GitHub
- URL: https://github.com/daggerok/avoiding-reactor-meltdown
- Owner: daggerok
- License: mit
- Created: 2020-02-03T12:14:54.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-03T15:28:10.000Z (about 6 years ago)
- Last Synced: 2025-04-05T10:23:18.130Z (10 months ago)
- Topics: block-hound, blockhound, blocking, reactor, reactor-blockhound, reactor-debug-agent, reactor-tools, spring-webflux, webflux
- Language: Java
- Homepage:
- Size: 64.5 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# how to block in reactor [](https://travis-ci.org/daggerok/avoiding-reactor-meltdown)
...when it's needed
## problem
In short: we should never block! But sometimes we just cannot avoid blocking calls...
For instance, when we have to use library which hasn't reactive non-blocking support,
and maybe even not planed to be reactive, legacy libraries, JDBC, ThreadLocal, etc...
## identify problem
* use [reactor-tools](name-service/src/main/java/daggerok/Main.java#L39)
* use [BlockHound](name-service/src/main/java/daggerok/Main.java#L38)
## solve problem
* bad: create separate microservice, which will call blocking one
* good: perform all blocking calls [in a separate thread](name-service/src/main/java/daggerok/Main.java#L120) provided by special defined scheduled
## run and test
1. start apps:
```bash
jdk11 ; ./mvnw -f mongo spring-boot:run
jdk11 ; ./mvnw -f name-service spring-boot:run
```
1. execute all REST API calls from [api.http](api.http) file
## resources
* [YouTube: Avoiding Reactor Meltdown](https://www.youtube.com/watch?v=xCu73WVg8Ps)