Class RabbitmqTaskQueue
java.lang.Object
org.duracloud.common.queue.rabbitmq.RabbitmqTaskQueue
- All Implemented Interfaces:
TaskQueue
RabbitMQ implementation of the TaskQueue
emulates the functionality of a queue.
- Author:
- Shibo Liu Date: 07/03/19
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRabbitmqTaskQueue(com.rabbitmq.client.Connection conn, String exchange, String queueName) RabbitmqTaskQueue(String host, Integer port, String vhost, String exchange, String username, String password, String queueName) Creates RabbitMQ task queue, a RabbitMQ server is needed and a DIRECT exchange must be created and bound to the queue name provided (routing key must be the same as the queue name) -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteTask(Task task) Deletes a task from the queue.voiddeleteTasks(Set<Task> tasks) Deletes a set of tasksvoidextendVisibilityTimeout(Task task) RabbitMQ does not have this feature, messages would not be visible until rejected and requeuedgetName()A name identifying the queue used for logging and analysis purposes.protected TaskmarshallTask(byte[] msgBody, long deliveryTag, String routingKey, String exchange) voidputs multiple tasks on the queue using batch puts if the queue implementation supports batch putsvoidputs 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
-
RabbitmqTaskQueue
public RabbitmqTaskQueue(String host, Integer port, String vhost, String exchange, String username, String password, String queueName) Creates RabbitMQ task queue, a RabbitMQ server is needed and a DIRECT exchange must be created and bound to the queue name provided (routing key must be the same as the queue name) -
RabbitmqTaskQueue
-
-
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
Description copied from interface:TaskQueueputs multiple tasks on the queue using batch puts if the queue implementation supports batch puts -
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
RabbitMQ does not have this feature, messages would not be visible until rejected and requeued- 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).
-