public class AbortableTaskDecorator
extends java.lang.Object
implements org.springframework.core.task.TaskDecorator
Constructor and Description |
---|
AbortableTaskDecorator(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor taskExecutor,
java.util.concurrent.ScheduledThreadPoolExecutor timeoutExecutor)
Construct an instance.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Runnable |
decorate(java.lang.Runnable runnable) |
public AbortableTaskDecorator(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor taskExecutor, java.util.concurrent.ScheduledThreadPoolExecutor timeoutExecutor)
public java.lang.Runnable decorate(java.lang.Runnable runnable)
We create a new AbortableTaskRunnable
that holds the current thread's MDC. This is for logging purposes, so that logging
within the runnable
is done with the correct logging context. For instance, the transaction id is logged and the current
user etc.
Next to this, we create an schedule a TimeoutGuardTask
. This task will stop the runnable we're decorating if the configured
timeout has lapsed.
The AbortableTaskRunnable
will stop the execution of the TimeoutGuardTask
after it completes.
decorate
in interface org.springframework.core.task.TaskDecorator