BlockHound detects problems that take down your reactive applications
It might not be that self-evident, but your non-blocking reactive application can block and eventually run out of computing power. It's simple to make that error.
All you have to do is use a blocking operation, and everything
falls apart like a house of cards. It can disguise itself as an undocumented method with an unintended side-effect or a misused dependency.
BlockHound can save you, so use it. All you need to do is to add it to your tests suite. Just like that.
class SuperImportantServiceTest {
@BeforeAll
fun setupAll() {
BlockHound.install();
}
...
}
For more information on adding a dependency to your project, you can check an official getting starter guide.
BlockHound works with Project Reactor & Kotlin coroutines
BlockHound is a tool created by Project Reactor's team, but you can use it with many different technologies. Here you can see examples of using BlockHound with Reactor & Kotlin coroutines. It supports the JVM's SPI mechanism for easy integration with any technology.
Sadly, RxJava 3 is unsupported at the moment. BlockHound still supports RxJava 2.
Nonetheless, BlockHound's versatile, and there is no reason you can't use it right now. Unless you use RxJava 3 😉
Together with Testcontainers can even detect problems with your external dependencies
Some blocking operations might hide inside dependencies that you use. Let's say that you use blocking MongoDB operations by mistake. If you only mock operations on a database, then BlockHound won't help you.
Use Testcontainers to solve this problem. It's a tool that spawns containers with dependencies during running tests. In doing so, you connect to an authentic MongoDB instance just for your tests. BlockHound instantly catches that you use blocking API and warns you about it.
Summary
Putting it all together, go and use BlockHound immediately. It's an essential tool for every software developer that creates reactive applications.
BlockHound is:
- easy to use & saves your good night sleep
- works with the most popular non-blocking JVM technologies
- together with Testcontainers is a bulletproof solution
Top comments (0)