Package com.github.sonus21.rqueue.core
Interface Job
-
- All Known Implementing Classes:
JobImpl
public interface JobOn each execution Rqueue creates a job to track it's status and execution progress.A job belongs to a single message poll, each message listener call creates an execution
Executionand that has a detail for specific execution. Overall job status can be found using this job interface. This object is available viaHeaderin listener method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcheckIn(java.io.Serializable message)Checkin allows you to display a message for long running tasks, so that you can see the progress.voiddelete(JobStatus status, java.io.Serializable why)Delete this jobContextgetContext()Return job contextjava.lang.ThrowablegetException()Any error detail, if it fails during executionlonggetExecutionTime()Total execution time of the fetched RqueueMessagesintgetFailureCount()Number of times this job has failedjava.lang.StringgetId()Get job id corresponding to a messageExecutiongetLatestExecution()Return latest execution datajava.lang.ObjectgetMessage()A message that was enqueuedjava.lang.StringgetMessageId()Get message id corresponding to this jobMessageMetadatagetMessageMetadata()MessageMetadata corresponding the enqueued messageQueueDetailgetQueueDetail()Queue detail on which this job was executingRqueueMessagegetRqueueMessage()RqueueMessage that's consumed by this jobJobStatusgetStatus()The current status of this job, the message can have different status.java.time.DurationgetVisibilityTimeout()Get current visibility timeout of this job, if visibility timeout has already elapsed than return zero valuebooleanhasMovedToDeadLetterQueue()Reports true when this job is moved to dead letter queuebooleanisDeleted()Return whether this job was deleted, this returns true in two casesbooleanisDiscarded()Whether this job is discarded or not, a message is discarded when it's all retries are over and no dead letter queue is configured.booleanisReleased()Whether this job is released back to the queue or not in two casesvoidrelease(JobStatus status, java.io.Serializable why)Release this job back to queue, this job available for execution after one second.voidrelease(JobStatus status, java.io.Serializable why, java.time.Duration duration)Release this job back to the queue, the released job would be available for re-execution after the duration time.voidsetContext(Context context)Set job contextbooleanupdateVisibilityTimeout(java.time.Duration deltaDuration)Update the visibility timeout of this job, the delta duration would be added in the current visibility timeout.
-
-
-
Method Detail
-
getId
java.lang.String getId()
Get job id corresponding to a message- Returns:
- string job id
-
getMessageId
java.lang.String getMessageId()
Get message id corresponding to this job- Returns:
- message id
-
getRqueueMessage
RqueueMessage getRqueueMessage()
RqueueMessage that's consumed by this job- Returns:
- an object of RqueueMessage
-
checkIn
void checkIn(java.io.Serializable message)
Checkin allows you to display a message for long running tasks, so that you can see the progress.The checking message could be anything given message's JSON serializable/deserializable. The message could be the current status of the job or anything else.
NOTE: Checkin is not allowed for periodic job
- Parameters:
message- a serializable message
-
getVisibilityTimeout
java.time.Duration getVisibilityTimeout()
Get current visibility timeout of this job, if visibility timeout has already elapsed than return zero value- Returns:
- remaining duration that this job can take, otherwise other listener will consume this message
-
updateVisibilityTimeout
boolean updateVisibilityTimeout(java.time.Duration deltaDuration)
Update the visibility timeout of this job, the delta duration would be added in the current visibility timeout. For example to add 10 seconds call this with Duration.ofSeconds(10), to subtract 10 seconds call this with Duration.ofSeconds(-10). This method returns when message exist in the processing queue, if message is already processed then it would return false.- Parameters:
deltaDuration- the delta time that needs to added to the existing visibility timeout- Returns:
- true/false whether this operation was success or not
-
getMessage
java.lang.Object getMessage()
A message that was enqueued- Returns:
- an object could be null if deserialization fail.
-
getMessageMetadata
MessageMetadata getMessageMetadata()
MessageMetadata corresponding the enqueued message- Returns:
- message metadata object
-
getStatus
JobStatus getStatus()
The current status of this job, the message can have different status.- Returns:
- job status
- See Also:
MessageMetadata
-
getException
java.lang.Throwable getException()
Any error detail, if it fails during execution- Returns:
- an error object
-
getExecutionTime
long getExecutionTime()
Total execution time of the fetched RqueueMessages- Returns:
- total execution time, that's sum of all listener method calls.
-
getQueueDetail
QueueDetail getQueueDetail()
Queue detail on which this job was executing- Returns:
- queue detail object
-
getLatestExecution
Execution getLatestExecution()
Return latest execution data- Returns:
- an execution object
-
getContext
Context getContext()
Return job context- Returns:
- job context
-
setContext
void setContext(Context context)
Set job context- Parameters:
context- context object
-
release
void release(JobStatus status, java.io.Serializable why, java.time.Duration duration)
Release this job back to the queue, the released job would be available for re-execution after the duration time.- Parameters:
status- job statuswhy- why do want to release this jobduration- any positive duration
-
release
void release(JobStatus status, java.io.Serializable why)
Release this job back to queue, this job available for execution after one second.- Parameters:
status- what should be the job statuswhy- why do you want to delete this job
-
delete
void delete(JobStatus status, java.io.Serializable why)
Delete this job- Parameters:
status- what should be the job statuswhy- why do you want to delete this job
-
isDeleted
boolean isDeleted()
Return whether this job was deleted, this returns true in two cases1. when message is deleted using
delete(JobStatus, Serializable)method2. Job's status is terminal status.
- Returns:
- true/false
-
isReleased
boolean isReleased()
Whether this job is released back to the queue or not in two casesWhen message was released using
release(JobStatus, Serializable)orrelease(JobStatus, Serializable, Duration)job is failed, so it will be retried later
- Returns:
- true/false
-
hasMovedToDeadLetterQueue
boolean hasMovedToDeadLetterQueue()
Reports true when this job is moved to dead letter queue- Returns:
- true/false
-
isDiscarded
boolean isDiscarded()
Whether this job is discarded or not, a message is discarded when it's all retries are over and no dead letter queue is configured.- Returns:
- true/false
-
getFailureCount
int getFailureCount()
Number of times this job has failed- Returns:
- failure count
-
-