Class TimeoutGuardTask

  • All Implemented Interfaces:
    Runnable

    public class TimeoutGuardTask
    extends Object
    implements Runnable
    Task that stops another scheduled task if the scheduled task's timeout has been reached.

    We first try to remove the scheduled task from the executor, so it will not be executed. If this fails we will try to abort the scheduled tasks.

    For this the guarded task must register it's TaskAbortStrategy in the SharedTaskContext.

    Since:
    2.0.0
    Author:
    Rutger Lubbers, Paul Klos
    • Constructor Detail

      • TimeoutGuardTask

        public TimeoutGuardTask​(@NotNull
                                @NotNull MdcContext mdcContext,
                                SharedTaskContext sharedTaskContext)
        Create a new TimeoutGuardTask instance with the given mdcContext and taskExecutor.
        Parameters:
        mdcContext - The Logging context to set
    • Method Detail

      • run

        public void run()

        When this method is run, the guardedTask is running longer than it's timeout.

        Specified by:
        run in interface Runnable