Class DistributedDelayQueue<T>
java.lang.Object
org.apache.curator.framework.recipes.queue.DistributedDelayQueue<T>
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- QueueBase<T>
A variation of the DistributedPriorityQueue that uses time as the priority. When items are added to the queue, a delay value is given. The item will not be sent to a consumer until the time elapses.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()booleanWait until any pending puts are committedintReturn the most recent message count from the queue.Return the manager for put listenersvoidAdd an item into the queue.booleanSame asput(Object, long)but allows a maximum wait time if an upper bound was set viaQueueBuilder.maxItems.voidAdd a set of items with the same priority into the queue.booleanSame asputMulti(MultiItem, long)but allows a maximum wait time if an upper bound was set viaQueueBuilder.maxItems.voidsetErrorMode(ErrorMode newErrorMode) Used when the queue is created with aQueueBuilder.lockPath(String).voidstart()Start the queue.
- 
Method Details- 
startStart the queue. No other methods work until this is called
- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException
 
- 
putAdd an item into the queue. Adding is done in the background - thus, this method will return quickly.
 NOTE: if an upper bound was set viaQueueBuilder.maxItems, this method will block until there is available space in the queue.- Parameters:
- item- item to add
- delayUntilEpoch- future epoch (milliseconds) when this item will be available to consumers
- Throws:
- Exception- connection issues
 
- 
putSame asput(Object, long)but allows a maximum wait time if an upper bound was set viaQueueBuilder.maxItems.- Parameters:
- item- item to add
- delayUntilEpoch- future epoch (milliseconds) when this item will be available to consumers
- maxWait- maximum wait
- unit- wait unit
- Returns:
- true if items was added, false if timed out
- Throws:
- Exception
 
- 
putMultiAdd a set of items with the same priority into the queue. Adding is done in the background - thus, this method will return quickly.
 NOTE: if an upper bound was set viaQueueBuilder.maxItems, this method will block until there is available space in the queue.- Parameters:
- items- items to add
- delayUntilEpoch- future epoch (milliseconds) when this item will be available to consumers
- Throws:
- Exception- connection issues
 
- 
putMultipublic boolean putMulti(MultiItem<T> items, long delayUntilEpoch, int maxWait, TimeUnit unit) throws Exception Same asputMulti(MultiItem, long)but allows a maximum wait time if an upper bound was set viaQueueBuilder.maxItems.- Parameters:
- items- items to add
- delayUntilEpoch- future epoch (milliseconds) when this item will be available to consumers
- maxWait- maximum wait
- unit- wait unit
- Returns:
- true if items was added, false if timed out
- Throws:
- Exception
 
- 
setErrorModeDescription 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 interface- QueueBase<T>
- Parameters:
- newErrorMode- the new error mode (the default is- ErrorMode.REQUEUE
 
- 
flushPutsDescription copied from interface:QueueBaseWait until any pending puts are committed- Specified by:
- flushPutsin interface- QueueBase<T>
- Parameters:
- waitTime- max wait time
- timeUnit- time unit
- Returns:
- true if the flush was successful, false if it timed out first
- Throws:
- InterruptedException- if thread was interrupted
 
- 
getPutListenerContainerReturn the manager for put listeners- Specified by:
- getPutListenerContainerin interface- QueueBase<T>
- Returns:
- put listener container
 
- 
getLastMessageCountpublic int getLastMessageCount()Return the most recent message count from the queue. This is useful for debugging/information purposes only.- Specified by:
- getLastMessageCountin interface- QueueBase<T>
- Returns:
- count (can be 0)
 
 
-