Class DistributedIdQueue<T>
java.lang.Object
org.apache.curator.framework.recipes.queue.DistributedIdQueue<T>
- All Implemented Interfaces:
Closeable,AutoCloseable,QueueBase<T>
A version of
DistributedQueue that allows IDs to be associated with queue items. Items
can then be removed from the queue if needed-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanWait until any pending puts are committedintReturn the most recent message count from the queue.org.apache.curator.framework.listen.Listenable<QueuePutListener<T>> Return the manager for put listenersvoidPut an item into the queue with the given Id
NOTE: if an upper bound was set viaQueueBuilder.maxItems, this method will block until there is available space in the queue.booleanSame asput(Object, String)but allows a maximum wait time if an upper bound was set viaQueueBuilder.maxItems.intRemove any items with the given IdvoidsetErrorMode(ErrorMode newErrorMode) Used when the queue is created with aQueueBuilder.lockPath(String).voidstart()Start the queue.
-
Method Details
-
start
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getPutListenerContainer
public org.apache.curator.framework.listen.Listenable<QueuePutListener<T>> getPutListenerContainer()Description copied from interface:QueueBaseReturn the manager for put listeners- Specified by:
getPutListenerContainerin interfaceQueueBase<T>- Returns:
- put listener container
-
setErrorMode
Description copied from interface:QueueBaseUsed when the queue is created with aQueueBuilder.lockPath(String). Determines the behavior when the queue consumer throws an exception- Specified by:
setErrorModein interfaceQueueBase<T>- Parameters:
newErrorMode- the new error mode (the default isErrorMode.REQUEUE
-
flushPuts
Description copied from interface:QueueBaseWait until any pending puts are committed- Specified by:
flushPutsin interfaceQueueBase<T>- Parameters:
waitTime- max wait timetimeUnit- time unit- Returns:
- true if the flush was successful, false if it timed out first
- Throws:
InterruptedException- if thread was interrupted
-
getLastMessageCount
public int getLastMessageCount()Description copied from interface:QueueBaseReturn the most recent message count from the queue. This is useful for debugging/information purposes only.- Specified by:
getLastMessageCountin interfaceQueueBase<T>- Returns:
- count (can be 0)
-
put
-
put
Same asput(Object, String)but allows a maximum wait time if an upper bound was set viaQueueBuilder.maxItems.- Parameters:
item- itemitemId- item IdmaxWait- maximum waitunit- wait unit- Returns:
- true if items was added, false if timed out
- Throws:
Exception
-
remove
-