Interface IQueue
- All Known Implementing Classes:
ChroniclePersistentQueue,InMemoryQueue,PersistentFileQueue,PersistentInMemoryQueue
public interface IQueue
IQueue interface.
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(byte[] itemBody) add message to queue.voidadd message to queue.voidclear()Clears the queue.voidcommit(IQueueable object) Removes polled object from the queue.voidcommit(IQueueable[] batchItems, int size) Removes polled objects from the queue.voidfailedProcessing(IQueueable items) Return element to queue.voidfailedProcessing(IQueueable[] batchItems, int size) Return element to queue.voidInitializes queue.booleanisEmpty()Checks if queue is currently empty.poll()Poll object from the queue (doesn't remove it from queue yet!).voidshutdown()Gracefully shutdowns queue.intsize()Returns current queue size.take()Retrieves and mark as processing the head of this queue, waiting if necessary until an element becomes available.inttake(IQueueable[] batch) Retrieves and mark as processing the batch elements from head of this queue, waiting if necessary until at least one element becomes available.
-
Method Details
-
add
add message to queue.- Parameters:
itemBody-- Throws:
InterruptedExceptionIOException
-
add
add message to queue.- Parameters:
itemBody-- Throws:
InterruptedExceptionIOException
-
poll
IQueueable poll()Poll object from the queue (doesn't remove it from queue yet!). Change tem state to processing.- Returns:
- the head of this queue, or
nullif this queue is empty - See Also:
-
take
IQueueable take()Retrieves and mark as processing the head of this queue, waiting if necessary until an element becomes available.- Returns:
- the head of this queue
- Throws:
IllegalStateException- if interrupted while waiting
-
take
Retrieves and mark as processing the batch elements from head of this queue, waiting if necessary until at least one element becomes available.- Returns:
- the number of read elements
- Throws:
IllegalStateException- if interrupted while waiting
-
failedProcessing
Return element to queue. Item will be available again for handing.- Parameters:
items-
-
failedProcessing
Return element to queue. Items will be available again for handing.- Parameters:
batchItems-size- the number of items in batch
-
commit
Removes polled object from the queue.- Parameters:
object-- Throws:
IOException
-
commit
Removes polled objects from the queue.- Parameters:
batchItems-size- the number of items in batch- Throws:
IOException
-
isEmpty
boolean isEmpty()Checks if queue is currently empty.- Returns:
- true if empty
-
size
int size()Returns current queue size.- Returns:
- queue size
-
clear
Clears the queue.- Throws:
IOException
-
shutdown
void shutdown()Gracefully shutdowns queue. -
initialize
Initializes queue. That includes restore of previously saved queue content for persistent queues.- Throws:
IOException
-