Class Task<PayloadT>

  • Type Parameters:
    PayloadT - The type of the payload in the task

    public final class Task<PayloadT>
    extends java.lang.Object
    Typed task wrapper with parameters, which is supplied to the QueueConsumer task processor
    Since:
    10.07.2017
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <PayloadBuilderT>
      Task.Builder<PayloadBuilderT>
      builder​(QueueShardId shardId)
      Creates a builder for Task objects.
      boolean equals​(java.lang.Object obj)  
      long getAttemptsCount()
      Get number of attempts to execute the task, including the current one.
      java.time.ZonedDateTime getCreatedAt()
      Get date and time when the task was added into the queue.
      java.util.Map<java.lang.String,​java.lang.String> getExtData()
      Get the map of external user-defined parameters, where the key is the column name in the tasks table.
      java.util.Optional<PayloadT> getPayload()
      Get typed task payload.
      PayloadT getPayloadOrThrow()
      Get typed task payload or throw IllegalArgumentException if not present.
      long getReenqueueAttemptsCount()
      Get number of attempts to postpone (re-enqueue) the task.
      QueueShardId getShardId()
      Get the shard identifier from which the task executor took the task.
      long getTotalAttemptsCount()
      Get sum of all attempts to execute the task, including all task re-enqueue attempts and all failed attempts.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getPayload

        @Nonnull
        public java.util.Optional<PayloadT> getPayload()
        Get typed task payload.
        Returns:
        Typed task payload.
      • getPayloadOrThrow

        @Nonnull
        public PayloadT getPayloadOrThrow()
        Get typed task payload or throw IllegalArgumentException if not present.
        Returns:
        Typed task payload.
      • getAttemptsCount

        public long getAttemptsCount()
        Get number of attempts to execute the task, including the current one.
        Returns:
        Number of attempts to execute the task.
      • getReenqueueAttemptsCount

        public long getReenqueueAttemptsCount()
        Get number of attempts to postpone (re-enqueue) the task.
        Returns:
        Number of attempts to postpone (re-enqueue) the task.
      • getTotalAttemptsCount

        public long getTotalAttemptsCount()
        Get sum of all attempts to execute the task, including all task re-enqueue attempts and all failed attempts.
        This counter should never be reset.
        Returns:
        Sum of all attempts to execute the task.
      • getCreatedAt

        @Nonnull
        public java.time.ZonedDateTime getCreatedAt()
        Get date and time when the task was added into the queue.
        Returns:
        Date and time when the task was added into the queue.
      • getShardId

        @Nonnull
        public QueueShardId getShardId()
        Get the shard identifier from which the task executor took the task.
        Returns:
        Shard identifier from which the task executor took the task.
      • getExtData

        @Nonnull
        public java.util.Map<java.lang.String,​java.lang.String> getExtData()
        Get the map of external user-defined parameters, where the key is the column name in the tasks table.
        Returns:
        Map of external user-defined parameters, where the key is the column name in the tasks table.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • builder

        public static <PayloadBuilderT> Task.Builder<PayloadBuilderT> builder​(@Nonnull
                                                                              QueueShardId shardId)
        Creates a builder for Task objects.
        Type Parameters:
        PayloadBuilderT - A type of task payload.
        Parameters:
        shardId - An id of shard.
        Returns:
        A new instance of the Task.Builder builder.