Class DistributedIdQueue<T>
- java.lang.Object
-
- org.apache.curator.framework.recipes.queue.DistributedIdQueue<T>
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,QueueBase<T>
public class DistributedIdQueue<T> extends java.lang.Object implements QueueBase<T>
A version ofDistributedQueuethat allows IDs to be associated with queue items. Items can then be removed from the queue if needed
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()booleanflushPuts(long waitTime, java.util.concurrent.TimeUnit timeUnit)Wait until any pending puts are committedintgetLastMessageCount()Return the most recent message count from the queue.org.apache.curator.framework.listen.ListenerContainer<QueuePutListener<T>>getPutListenerContainer()Return the manager for put listenersvoidput(T item, java.lang.String itemId)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.booleanput(T item, java.lang.String itemId, int maxWait, java.util.concurrent.TimeUnit unit)Same asput(Object, String)but allows a maximum wait time if an upper bound was set viaQueueBuilder.maxItems.intremove(java.lang.String id)Remove any items with the given IdvoidsetErrorMode(ErrorMode newErrorMode)Used when the queue is created with aQueueBuilder.lockPath(String).voidstart()Start the queue.
-
-
-
Method Detail
-
start
public void start() throws java.lang.ExceptionDescription copied from interface:QueueBaseStart the queue. No other methods work until this is called
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getPutListenerContainer
public org.apache.curator.framework.listen.ListenerContainer<QueuePutListener<T>> getPutListenerContainer()
Description copied from interface:QueueBaseReturn the manager for put listeners- Specified by:
getPutListenerContainerin interfaceQueueBase<T>- Returns:
- put listener container
-
setErrorMode
public void setErrorMode(ErrorMode newErrorMode)
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
public boolean flushPuts(long waitTime, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedExceptionDescription copied from interface:QueueBaseWait until any pending puts are committed
-
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
public void put(T item, java.lang.String itemId) throws java.lang.Exception
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:
java.lang.Exception- errors
-
put
public boolean put(T item, java.lang.String itemId, int maxWait, java.util.concurrent.TimeUnit unit) throws java.lang.Exception
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:
java.lang.Exception
-
remove
public int remove(java.lang.String id) throws java.lang.ExceptionRemove any items with the given Id- Parameters:
id- item Id to remove- Returns:
- number of items removed
- Throws:
java.lang.Exception- errors
-
-