Skip to content

long running scheduled task #45843

Answered by manovotn
CluelessAardvark asked this question in Q&A
Discussion options

You must be logged in to vote

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 or ManagedExecutor. 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.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@CluelessAardvark
Comment options

@manovotn
Comment options

Answer selected by CluelessAardvark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants