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.
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:
implementation
or testimplementation
in your dependencies with either oi.projectreactor.tools:blockhound:1.0.4.RELEASE
or io.projectreactor.tools:blockhound-junit-platform:1.0.4.RELEASE
and then do BlockHound.install()
in either your main application code or your test. –
Tabatha © 2022 - 2024 — McMap. All rights reserved.