Package org.duracloud.common.queue.aws
Class SQSTaskQueue
java.lang.Object
org.duracloud.common.queue.aws.SQSTaskQueue
- All Implemented Interfaces:
TaskQueue
SQSTaskQueue acts as the interface for interacting with an Amazon
Simple Queue Service (SQS) queue.
This class provides a way to interact with a remote SQS Queue, it
emulates the functionality of a queue.
- Author:
- Erik Paulsson Date: 10/21/13
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSQSTaskQueue(com.amazonaws.services.sqs.AmazonSQS sqsClient, String queueName) SQSTaskQueue(String queueName) Creates a SQSTaskQueue that serves as a handle to interacting with a remote Amazon SQS Queue. -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteTask(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.getName()A name identifying the queue used for logging and analysis purposes.protected TaskmarshallTask(com.amazonaws.services.sqs.model.Message msg) voidPuts multiple tasks on the queue using batch puts.voidputs a task on the queuevoidConvenience method that calls put(Set) voidRequeues the task by deleting the task, incrementing the "attempts" counter, and re-adding back to the queue.size()take()Blocks until a task is availabletake(int maxTasks) Take a max of specified number of tasks.protected StringunmarshallTask(Task task)
-
Constructor Details
-
SQSTaskQueue
Creates a SQSTaskQueue that serves as a handle to interacting with a remote Amazon SQS Queue. The AmazonSQSClient will search for Amazon credentials on the system as described here: http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html Moreover, it is possible to set the region to use via the AWS_REGION environment variable or one of the other methods described here: http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/java-dg-region-selection.html -
SQSTaskQueue
-
-
Method Details
-
getName
Description copied from interface:TaskQueueA name identifying the queue used for logging and analysis purposes. -
marshallTask
-
unmarshallTask
-
put
Description copied from interface:TaskQueueputs a task on the queue -
put
Convenience method that calls put(Set) -
put
Puts multiple tasks on the queue using batch puts. The tasks argument can contain more than 10 Tasks, in that case there will be multiple SQS batch send requests made each containing up to 10 messages. -
take
Description copied from interface:TaskQueueTake a max of specified number of tasks. Blocks until at least one task is available.- Specified by:
takein interfaceTaskQueue- Parameters:
maxTasks- to take from queue. Must be between 1 and 10 inclusive.- Returns:
- Throws:
TimeoutException
-
take
Description copied from interface:TaskQueueBlocks until a task is available- Specified by:
takein interfaceTaskQueue- Returns:
- Throws:
TimeoutException
-
extendVisibilityTimeout
Description copied from interface:TaskQueueResponsible for robustly extending the visibility timeout of a Task.- Specified by:
extendVisibilityTimeoutin interfaceTaskQueue- Throws:
TaskNotFoundException
-
deleteTask
Description copied from interface:TaskQueueDeletes a task from the queue.- Specified by:
deleteTaskin interfaceTaskQueue- Throws:
TaskNotFoundException
-
deleteTasks
Description copied from interface:TaskQueueDeletes a set of tasks- Specified by:
deleteTasksin interfaceTaskQueue- Throws:
TaskException
-
requeue
Description copied from interface:TaskQueueRequeues 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. -
size
-
sizeIncludingInvisibleAndDelayed
- Specified by:
sizeIncludingInvisibleAndDelayedin interfaceTaskQueue- 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).
-