Package org.duracloud.common.queue
Interface TaskQueue
-
- All Known Implementing Classes:
LocalTaskQueue,NoopTaskQueue,RabbitMQTaskQueue,SQSTaskQueue
public interface TaskQueue- Author:
- Daniel Bernstein
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voiddeleteTask(Task task)Deletes a task from the queue.voiddeleteTasks(Set<Task> tasks)Deletes a set of tasksvoidextendVisibilityTimeout(Task task)Responsible for robustly extending the visibility timeout of a Task.StringgetName()A name identifying the queue used for logging and analysis purposes.voidput(Set<Task> tasks)puts multiple tasks on the queue using batch puts if the queue implementation supports batch putsvoidput(Task task)puts a task on the queuevoidput(Task... tasks)puts multiple tasks on the queue using batch puts if the queue implementation supports batch putsvoidrequeue(Task task)Requeues the task by deleting the task, incrementing the "attempts" counter, and re-adding back to the queue.Integersize()IntegersizeIncludingInvisibleAndDelayed()Tasktake()Blocks until a task is availableSet<Task>take(int maxTasks)Take a max of specified number of tasks.
-
-
-
Method Detail
-
getName
String getName()
A name identifying the queue used for logging and analysis purposes.- Returns:
-
put
void put(Task task)
puts a task on the queue- Parameters:
task-
-
put
void put(Task... tasks)
puts multiple tasks on the queue using batch puts if the queue implementation supports batch puts- Parameters:
tasks-
-
put
void put(Set<Task> tasks)
puts multiple tasks on the queue using batch puts if the queue implementation supports batch puts- Parameters:
tasks-
-
take
Task take() throws TimeoutException
Blocks until a task is available- Returns:
- Throws:
TimeoutException
-
take
Set<Task> take(int maxTasks) throws TimeoutException
Take a max of specified number of tasks. Blocks until at least one task is available.- Parameters:
maxTasks- to take from queue. Must be between 1 and 10 inclusive.- Returns:
- Throws:
TimeoutException
-
extendVisibilityTimeout
void extendVisibilityTimeout(Task task) throws TaskNotFoundException
Responsible for robustly extending the visibility timeout of a Task.- Parameters:
task-- Throws:
TaskNotFoundException
-
deleteTask
void deleteTask(Task task) throws TaskNotFoundException
Deletes a task from the queue.- Parameters:
task-- Throws:
TaskNotFoundException
-
deleteTasks
void deleteTasks(Set<Task> tasks) throws TaskException
Deletes a set of tasks- Parameters:
tasks-- Throws:
TaskException
-
size
Integer size()
- Returns:
- The approximate number of elements in this queue (does not include invisible and delayed tasks).
-
sizeIncludingInvisibleAndDelayed
Integer sizeIncludingInvisibleAndDelayed()
- Returns:
- The approximate number of elements in this queue including all items that are visible (available for takes), invisible (in process - not yet completed), and delayed (pending addition to the queue).
-
requeue
void requeue(Task task)
Requeues the task by deleting the task, incrementing the "attempts" counter, and re-adding back to the queue. Any subsequent calls on the requeued task via the task queue should fail due to the task not being found.- Parameters:
task-
-
-