Class RabbitmqTaskQueue
- java.lang.Object
-
- org.duracloud.common.queue.rabbitmq.RabbitmqTaskQueue
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RabbitmqTaskQueue.MsgProp
-
Constructor Summary
Constructors Constructor Description RabbitmqTaskQueue(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteTask(Task task)
Deletes a task from the queue.void
deleteTasks(Set<Task> tasks)
Deletes a set of tasksvoid
extendVisibilityTimeout(Task task)
RabbitMQ does not have this feature, messages would not be visible until rejected and requeuedString
getName()
A name identifying the queue used for logging and analysis purposes.protected Task
marshallTask(byte[] msgBody, long deliveryTag, String routingKey, String exchange)
void
put(Set<Task> tasks)
puts multiple tasks on the queue using batch puts if the queue implementation supports batch putsvoid
put(Task task)
puts a task on the queuevoid
put(Task... tasks)
Convenience method that calls put(Set) void
requeue(Task task)
Requeues the task by deleting the task, incrementing the "attempts" counter, and re-adding back to the queue.Integer
size()
Integer
sizeIncludingInvisibleAndDelayed()
Task
take()
Blocks until a task is availableSet<Task>
take(int maxTasks)
Take a max of specified number of tasks.protected String
unmarshallTask(Task task)
-
-
-
Constructor Detail
-
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)
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:TaskQueue
A name identifying the queue used for logging and analysis purposes.
-
marshallTask
protected Task marshallTask(byte[] msgBody, long deliveryTag, String routingKey, String exchange)
-
put
public void put(Task task)
Description copied from interface:TaskQueue
puts a task on the queue
-
put
public void put(Task... tasks)
Convenience method that calls put(Set)
-
put
public void put(Set<Task> tasks)
Description copied from interface:TaskQueue
puts multiple tasks on the queue using batch puts if the queue implementation supports batch puts
-
take
public Set<Task> take(int maxTasks) throws TimeoutException
Description copied from interface:TaskQueue
Take a max of specified number of tasks. Blocks until at least one task is available.- Specified by:
take
in interfaceTaskQueue
- Parameters:
maxTasks
- to take from queue. Must be between 1 and 10 inclusive.- Returns:
- Throws:
TimeoutException
-
take
public Task take() throws TimeoutException
Description copied from interface:TaskQueue
Blocks until a task is available- Specified by:
take
in interfaceTaskQueue
- Returns:
- Throws:
TimeoutException
-
extendVisibilityTimeout
public void extendVisibilityTimeout(Task task) throws TaskNotFoundException
RabbitMQ does not have this feature, messages would not be visible until rejected and requeued- Specified by:
extendVisibilityTimeout
in interfaceTaskQueue
- Throws:
TaskNotFoundException
-
deleteTask
public void deleteTask(Task task) throws TaskNotFoundException
Description copied from interface:TaskQueue
Deletes a task from the queue.- Specified by:
deleteTask
in interfaceTaskQueue
- Throws:
TaskNotFoundException
-
deleteTasks
public void deleteTasks(Set<Task> tasks) throws TaskException
Description copied from interface:TaskQueue
Deletes a set of tasks- Specified by:
deleteTasks
in interfaceTaskQueue
- Throws:
TaskException
-
requeue
public void requeue(Task task)
Description copied from interface:TaskQueue
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.
-
size
public Integer size()
-
sizeIncludingInvisibleAndDelayed
public Integer sizeIncludingInvisibleAndDelayed()
- Specified by:
sizeIncludingInvisibleAndDelayed
in 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).
-
-