public class DistributedDelayQueue<T> extends Object implements Closeable, 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.
Modifier 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,
long delayUntilEpoch)
Add an item into the queue.
|
boolean |
put(T item,
long delayUntilEpoch,
int maxWait,
TimeUnit unit)
Same as
put(Object, long) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems . |
void |
putMulti(MultiItem<T> items,
long delayUntilEpoch)
Add a set of items with the same priority into the queue.
|
boolean |
putMulti(MultiItem<T> items,
long delayUntilEpoch,
int maxWait,
TimeUnit unit)
Same as
putMulti(MultiItem, long) but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems . |
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
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void put(T item, long delayUntilEpoch) throws Exception
QueueBuilder.maxItems
, this method will
block until there is available space in the queue.item
- item to adddelayUntilEpoch
- future epoch (milliseconds) when this item will be available to consumersException
- connection issuespublic boolean put(T item, long delayUntilEpoch, int maxWait, TimeUnit unit) throws Exception
put(Object, long)
but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems
.item
- item to adddelayUntilEpoch
- future epoch (milliseconds) when this item will be available to consumersmaxWait
- maximum waitunit
- wait unitException
public void putMulti(MultiItem<T> items, long delayUntilEpoch) throws Exception
QueueBuilder.maxItems
, this method will
block until there is available space in the queue.items
- items to adddelayUntilEpoch
- future epoch (milliseconds) when this item will be available to consumersException
- connection issuespublic boolean putMulti(MultiItem<T> items, long delayUntilEpoch, int maxWait, TimeUnit unit) throws Exception
putMulti(MultiItem, long)
but allows a maximum wait time if an upper bound was set
via QueueBuilder.maxItems
.items
- items to adddelayUntilEpoch
- future epoch (milliseconds) when this item will be available to consumersmaxWait
- maximum waitunit
- wait unitException
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 Listenable<QueuePutListener<T>> getPutListenerContainer()
getPutListenerContainer
in interface QueueBase<T>
public int getLastMessageCount()
getLastMessageCount
in interface QueueBase<T>
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.