public class DistributedIdQueue<T> extends Object implements QueueBase<T>
DistributedQueue
that allows IDs to be associated with queue items. Items
can then be removed from the queue if neededModifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
flushPuts(long waitTime,
TimeUnit timeUnit)
Wait until any pending puts are committed
|
int |
getLastMessageCount()
Return the most recent message count from the queue.
|
Listenable<QueuePutListener<T>> |
getPutListenerContainer()
Return the manager for put listeners
|
void |
put(T item,
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,
String itemId,
int maxWait,
TimeUnit unit)
Same as
put(Object, String) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems . |
int |
remove(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 Exception
QueueBase
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public Listenable<QueuePutListener<T>> getPutListenerContainer()
QueueBase
getPutListenerContainer
in interface QueueBase<T>
public void setErrorMode(ErrorMode newErrorMode)
QueueBase
QueueBuilder.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.REQUEUE
public boolean flushPuts(long waitTime, TimeUnit timeUnit) throws InterruptedException
QueueBase
flushPuts
in interface QueueBase<T>
waitTime
- max wait timetimeUnit
- time unitInterruptedException
- if thread was interruptedpublic int getLastMessageCount()
QueueBase
getLastMessageCount
in interface QueueBase<T>
public void put(T item, String itemId) throws Exception
QueueBuilder.maxItems
, this method will
block until there is available space in the queue.item
- itemitemId
- item IdException
- errorspublic boolean put(T item, String itemId, int maxWait, TimeUnit unit) throws 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 unitException
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.