java.io.Closeable, java.lang.AutoCloseable, QueueBase<T>public class DistributedIdQueue<T> extends java.lang.Object implements QueueBase<T>
DistributedQueue that allows IDs to be associated with queue items. Items
can then be removed from the queue if needed| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
boolean |
flushPuts(long waitTime,
java.util.concurrent.TimeUnit timeUnit) |
Wait until any pending puts are committed
|
int |
getLastMessageCount() |
Return the most recent message count from the queue.
|
org.apache.curator.framework.listen.ListenerContainer<QueuePutListener<T>> |
getPutListenerContainer() |
Return the manager for put listeners
|
void |
put(T item,
java.lang.String itemId) |
Put an item into the queue with the given Id
NOTE: if an upper bound was set via QueueBuilder.maxItems, this method will
block until there is available space in the queue. |
boolean |
put(T item,
java.lang.String itemId,
int maxWait,
java.util.concurrent.TimeUnit unit) |
Same as
put(Object, String) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems. |
int |
remove(java.lang.String id) |
Remove any items with the given Id
|
void |
setErrorMode(ErrorMode newErrorMode) |
Used when the queue is created with a
QueueBuilder.lockPath(String). |
void |
start() |
Start the queue.
|
public void start()
throws java.lang.Exception
QueueBasepublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionpublic org.apache.curator.framework.listen.ListenerContainer<QueuePutListener<T>> getPutListenerContainer()
QueueBasegetPutListenerContainer in interface QueueBase<T>public void setErrorMode(ErrorMode newErrorMode)
QueueBaseQueueBuilder.lockPath(String). Determines
the behavior when the queue consumer throws an exceptionsetErrorMode in interface QueueBase<T>newErrorMode - the new error mode (the default is ErrorMode.REQUEUEpublic boolean flushPuts(long waitTime,
java.util.concurrent.TimeUnit timeUnit)
throws java.lang.InterruptedException
QueueBasepublic int getLastMessageCount()
QueueBasegetLastMessageCount in interface QueueBase<T>public void put(T item, java.lang.String itemId) throws java.lang.Exception
QueueBuilder.maxItems, this method will
block until there is available space in the queue.item - itemitemId - item Idjava.lang.Exception - errorspublic boolean put(T item, java.lang.String itemId, int maxWait, java.util.concurrent.TimeUnit unit) throws java.lang.Exception
put(Object, String) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems.item - itemitemId - item IdmaxWait - maximum waitunit - wait unitjava.lang.Exceptionpublic int remove(java.lang.String id)
throws java.lang.Exception
id - item Id to removejava.lang.Exception - errorsCopyright © 2011–2018 The Apache Software Foundation. All rights reserved.