How to add BlockHound to spring boot app to detect blocking calls ?
I didn't find any examples for spring boot apps: https://github.com/reactor/BlockHound/blob/master/docs/quick_start.md
Any help will be appreciated.
IMHO, the wisest choice would be to enable BlockHound while the code is being exercised by JUnit tests.
To do so you simply need to import the https://mvnrepository.com/artifact/io.projectreactor.tools/blockhound-junit-platform dependency with test scope, which automatically initializes BlockHound when you launch your JUnit tests suite:
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound-junit-platform</artifactId>
<version>1.0.0.RC1</version>
<scope>test</scope>
</dependency>
Alternatively, if you intend to use BlockHound at all times - and not only during tests - you should instead import the following dependency:
<dependency>
<groupId>io.projectreactor.tools</groupId>
<artifactId>blockhound</artifactId>
<version>1.0.0.RC1</version>
</dependency>
And call BlockHound.install()
in your main method, just before bootstrapping your Spring Boot application:
@SpringBootApplication
public class BlockhoundDemoApplication {
public static void main(String[] args) {
BlockHound.install();
SpringApplication.run(BlockhoundDemoApplication.class, args);
}
}
For further reference you can refer to:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With