I'm searching a way to use scheduled tasks in a reactive API. I know that it uses the thread pool so it's not very compatible with the webflux components.
Do you have an equivalent to do the job?
There are several ways to do. Considering how you want to schedule it you can use following as well.
@Configuration
class ApplicationConfiguration() {
@PostConstruct
fun init() {
Flux.interval(Duration.ofMinutes(12))
.onBackpressureDrop()
.flatMap { /* some task that return Mono<T> */ }
.subscribeOn(Schedulers.boundedElastic())
.subscribe()
}
}
Please note subscribeOn(Schedulers.boundedElastic()) is not required unless the call is blocking. Also I am using onBackpressureDrop but your requirements may be different than that.