Interface IQueue
- All Known Implementing Classes:
ChroniclePersistentQueue
,InMemoryQueue
,PersistentFileQueue
,PersistentInMemoryQueue
public interface IQueue
IQueue interface.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(byte[] itemBody) add message to queue.void
add message to queue.void
clear()
Clears the queue.void
commit
(IQueueable object) Removes polled object from the queue.void
commit
(IQueueable[] batchItems, int size) Removes polled objects from the queue.void
failedProcessing
(IQueueable items) Return element to queue.void
failedProcessing
(IQueueable[] batchItems, int size) Return element to queue.void
Initializes queue.boolean
isEmpty()
Checks if queue is currently empty.poll()
Poll object from the queue (doesn't remove it from queue yet!).void
shutdown()
Gracefully shutdowns queue.int
size()
Returns current queue size.take()
Retrieves and mark as processing the head of this queue, waiting if necessary until an element becomes available.int
take
(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:
InterruptedException
IOException
-
add
add message to queue.- Parameters:
itemBody
-- Throws:
InterruptedException
IOException
-
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
null
if 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
-