Package ru.yoomoney.tech.dbqueue.api
Class Task<PayloadT>
- java.lang.Object
-
- ru.yoomoney.tech.dbqueue.api.Task<PayloadT>
-
- Type Parameters:
PayloadT- The type of the payload in the task
public final class Task<PayloadT> extends java.lang.ObjectTyped task wrapper with parameters, which is supplied to the QueueConsumer task processor- Since:
- 10.07.2017
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTask.Builder<PayloadBuilderT>Builder for theTaskwrapper.
-
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 forTaskobjects.booleanequals(java.lang.Object obj)longgetAttemptsCount()Get number of attempts to execute the task, including the current one.java.time.ZonedDateTimegetCreatedAt()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.PayloadTgetPayloadOrThrow()Get typed task payload or throw IllegalArgumentException if not present.longgetReenqueueAttemptsCount()Get number of attempts to postpone (re-enqueue) the task.QueueShardIdgetShardId()Get the shard identifier from which the task executor took the task.longgetTotalAttemptsCount()Get sum of all attempts to execute the task, including all task re-enqueue attempts and all failed attempts.inthashCode()java.lang.StringtoString()
-
-
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
builder
public static <PayloadBuilderT> Task.Builder<PayloadBuilderT> builder(@Nonnull QueueShardId shardId)
Creates a builder forTaskobjects.- Type Parameters:
PayloadBuilderT- A type of task payload.- Parameters:
shardId- An id of shard.- Returns:
- A new instance of the
Task.Builderbuilder.
-
-