ScheduledExecutorService.scheduleWithFixedDelay usage in vertx

414 views Asked by At

I would like schedule a task that gets executed periodically after the completion of task. Previously I used ScheduledExecutorService.scheduleWithFixedDelay but now in vertx I am thinking whether it may cause any issue since vertx already uses thread for event loop and worker verticles.

I checked Vertx.setPeriodic, but that just executes periodically without checking or waiting for the task to complete before scheduling other.

With all options explored currently I have a workaround where I use Vertx.setTimer to schedule the task and on completion I am calling Vertx.setTimer again inside the handler.

On high level the schedule task will query records from one table and update other table.

Anyone has any other better solution, please guide me.

Vertx version - 3.9.4

1

There are 1 answers

6
Alexey Soshin On BEST ANSWER

To my best knowledge ScheduledExecutorService.scheduleWithFixedDelay shouldn't cause any problems with Vert.x, and you can continue using it.

Your suggestion of setting timer in a callback is the better way of solving that, though.