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 TypeMethodDescriptionvoid
close()
boolean
Wait until any pending puts are committedint
Return the most recent message count from the queue.Return the manager for put listenersvoid
Put 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.boolean
Same asput(Object, String)
but allows a maximum wait time if an upper bound was set viaQueueBuilder.maxItems
.int
Remove any items with the given Idvoid
setErrorMode
(ErrorMode newErrorMode) Used when the queue is created with aQueueBuilder.lockPath(String)
.void
start()
Start the queue.
-
Method Details
-
start
Description copied from interface:QueueBase
Start the queue. No other methods work until this is called -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getPutListenerContainer
Description copied from interface:QueueBase
Return the manager for put listeners- Specified by:
getPutListenerContainer
in interfaceQueueBase<T>
- Returns:
- put listener container
-
setErrorMode
Description copied from interface:QueueBase
Used when the queue is created with aQueueBuilder.lockPath(String)
. Determines the behavior when the queue consumer throws an exception- Specified by:
setErrorMode
in interfaceQueueBase<T>
- Parameters:
newErrorMode
- the new error mode (the default isErrorMode.REQUEUE
-
flushPuts
Description copied from interface:QueueBase
Wait until any pending puts are committed- Specified by:
flushPuts
in 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:QueueBase
Return the most recent message count from the queue. This is useful for debugging/information purposes only.- Specified by:
getLastMessageCount
in interfaceQueueBase<T>
- Returns:
- count (can be 0)
-
put
Put 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.- Parameters:
item
- itemitemId
- item Id- Throws:
Exception
- errors
-
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
Remove any items with the given Id- Parameters:
id
- item Id to remove- Returns:
- number of items removed
- Throws:
Exception
- errors
-