Class SharedTaskContext


  • public class SharedTaskContext
    extends Object
    The strategy is used by the TimeoutGuardTask to stop a running guarded task.

    This class is called shared since it is shared by the guarded task and the guard task in order to communicate the task abort strategy.

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

      • setTaskRemoveStrategy

        public void setTaskRemoveStrategy​(TaskRemoveStrategy taskRemoveStrategy)
        Register the task removal strategy.
        Parameters:
        taskRemoveStrategy - The TaskRemoveStrategy to share.
      • setTimeoutGuardTaskRemoveStrategy

        public void setTimeoutGuardTaskRemoveStrategy​(TaskRemoveStrategy timeoutGuardTaskRemoveStrategy)
        Register the timeout guard task removal strategy.
        Parameters:
        timeoutGuardTaskRemoveStrategy - the TaskRemoveStrategy to set.
      • setTaskAbortStrategy

        public void setTaskAbortStrategy​(TaskAbortStrategy taskAbortStrategy)
        Register the task abort strategy.
        Parameters:
        taskAbortStrategy - The TaskAbortStrategy to share.
      • abortBusinessTask

        public void abortBusinessTask()
        Invoke the taskAbortStrategy.
      • getTaskId

        public String getTaskId()
        Get the task's id.
        Returns:
        The task's id.
      • getTaskName

        public String getTaskName()
        Retrieve the task's name.
        Returns:
        The task's name.
      • isAborted

        public boolean isAborted()
        Has the task been aborted?
      • timeout

        public void timeout()
        Remove the guarded task from the queue, or else abort the running guarded task.
      • finish

        public void finish()
        This method is invoked when the guarded task is finished.

        It will perform cleanups. The finish should always be invoked.

      • getTaskStatistics

        public TaskStatistics getTaskStatistics()
        Return the task's execution statistics.
      • startExecution

        public void startExecution()
        Signal the start of the task's execution.
      • registerLogFields

        public void registerLogFields()
        Registers log fields using the current log context.
      • removeLogFields

        public void removeLogFields()
        Clears the kibana log fields.