long running scheduled task #45843
-
i would assume that this is a pretty common use case, e.g. sync, housekeeping, reporting and stuff like that. but i couldnt really find a blueprint specifically for that, so i used https://quarkus.io/guides/scheduler. my code looks exactly like that, only that my schedule is something like 'once a day' and my task is not just updating a counter but doing stuff that takes up to 30 minutes. but of course if i do it that way, i get lots of warnings (with full stack traces):
so my question is: am i doing it wrong? and if not, is there a way to suppress the warnings for this task specifically? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I think you would need an executor to delegate the task to so that you don't block the thread used for scheduler invocations. Another thing is that you can |
Beta Was this translation helpful? Give feedback.
I think you would need an executor to delegate the task to so that you don't block the thread used for scheduler invocations.
You can still use scheduler to trigger the task regularly but offload the task itself to another thread.
From the top of my head, I recall you can
@Inject ExecutorService
orManagedExecutor
. The latter allows for some context propagation but that might end up being more complicated if your tasks are this long.Another thing is that you can
@Inject ScheduledExecutorService
- with this you could schedule either a one-off task or even a periodic one so based on what exactly you need, this could replace the scheduler altogether.