Class CompositeTaskLifecycleListener

  • All Implemented Interfaces:
    TaskLifecycleListener

    public class CompositeTaskLifecycleListener
    extends java.lang.Object
    implements TaskLifecycleListener
    Composite listener. It allows combining several listeners into one. Listeners for picked and started events are executed in straight order. Listeners for executed, finished and crashed events are executed in reverse order.
    Since:
    11.06.2021
    • Constructor Detail

      • CompositeTaskLifecycleListener

        public CompositeTaskLifecycleListener​(@Nonnull
                                              java.util.List<TaskLifecycleListener> listeners)
        Constructor
        Parameters:
        listeners - task listeners
    • Method Detail

      • picked

        public void picked​(@Nonnull
                           QueueShardId shardId,
                           @Nonnull
                           QueueLocation location,
                           @Nonnull
                           TaskRecord taskRecord,
                           long pickTaskTime)
        Description copied from interface: TaskLifecycleListener
        Event of task picking from the queue.

        Triggered when there is a task in the queue, which is ready for processing.

        Might be useful for monitoring problems with database performance.

        Specified by:
        picked in interface TaskLifecycleListener
        Parameters:
        shardId - Shard identifier, which processes the queue.
        location - Queue location.
        taskRecord - Raw task data.
        pickTaskTime - Time spent on picking the task from the queue in millis.
      • started

        public void started​(@Nonnull
                            QueueShardId shardId,
                            @Nonnull
                            QueueLocation location,
                            @Nonnull
                            TaskRecord taskRecord)
        Description copied from interface: TaskLifecycleListener
        The start event of task processing.

        Always triggered when task was picked.

        Might be useful for updating a logging context.

        Specified by:
        started in interface TaskLifecycleListener
        Parameters:
        shardId - Shard identifier, which processes the queue.
        location - Queue location.
        taskRecord - Raw task data.
      • executed

        public void executed​(@Nonnull
                             QueueShardId shardId,
                             @Nonnull
                             QueueLocation location,
                             @Nonnull
                             TaskRecord taskRecord,
                             @Nonnull
                             TaskExecutionResult executionResult,
                             long processTaskTime)
        Description copied from interface: TaskLifecycleListener
        Event for completion of client logic when task processing.

        Always triggered when task processing has completed successfully.

        Might be useful for monitoring successful execution of client logic.

        Specified by:
        executed in interface TaskLifecycleListener
        Parameters:
        shardId - Shard identifier, which processes the queue.
        location - Queue location.
        taskRecord - Raw task data.
        executionResult - Result of task processing.
        processTaskTime - Time spent on task processing in millis, without the time for task picking from the queue.
      • crashed

        public void crashed​(@Nonnull
                            QueueShardId shardId,
                            @Nonnull
                            QueueLocation location,
                            @Nonnull
                            TaskRecord taskRecord,
                            @Nullable
                            java.lang.Exception exc)
        Description copied from interface: TaskLifecycleListener
        Event for abnormal queue processing.

        Triggered when unexpected error occurs during task processing.

        Might be useful for tracking and monitoring errors in the system.

        Specified by:
        crashed in interface TaskLifecycleListener
        Parameters:
        shardId - Shard identifier, which processes the queue.
        location - Queue location.
        taskRecord - Raw task data.
        exc - An error caused the crash.