| Constructor and Description |
|---|
RichBDBQueue(File queueBaseDir,
String queueName,
int cacheSize,
Class<T> type)
Constructs the queue using the given file for persistence.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
close()
Close the queue and release the thread processing
consume(Consumer) is there is any. |
void |
consume(Consumer<T> consumer)
Consume the queue using the given consumer.
|
protected org.codehaus.jackson.map.ObjectMapper |
createObjectMapper()
Create the
ObjectMapper used for serializing. |
long |
getPauseTimeInMillis()
The time in millis that
consume(Consumer) goes to sleep when the queue
is empty before checking again. |
boolean |
isEmpty() |
T |
peek() |
void |
push(T object)
Serializes the given object and adds the serialized form to the queue file.
|
void |
remove() |
void |
setPauseTimeInMillis(long pauseTimeInMillis)
Sets the time in millis that
consume(Consumer) goes to sleep when the queue
is empty before checking again. |
long |
size() |
public RichBDBQueue(File queueBaseDir, String queueName, int cacheSize, Class<T> type) throws IOException
queueBaseDir - queue database environment directory pathqueueName - descriptive queue namecacheSize - how often to sync the queue to diskIOException - thrown when the given file does not exist or is not writeable.protected org.codehaus.jackson.map.ObjectMapper createObjectMapper()
ObjectMapper used for serializing.ObjectMapper.public void push(T object) throws IOException
object - the object to add.IOExceptionBDBQueue.push(byte[])public void consume(Consumer<T> consumer) throws IOException, InterruptedException
Consumer.consume(Object)). If the consumer
fails consuming it, the element will try again. Therefore, if you can't process the element
but want that it's removed, just handle your exception accordingly and don't throw an
exception.consumer - the consumer used for handling queue elements.IOExceptionInterruptedExceptionpublic void clear()
public void close()
consume(Consumer) is there is any.public boolean isEmpty()
public T peek() throws IOException
IOExceptionpublic void remove()
public long size()
public long getPauseTimeInMillis()
consume(Consumer) goes to sleep when the queue
is empty before checking again.public void setPauseTimeInMillis(long pauseTimeInMillis)
consume(Consumer) goes to sleep when the queue
is empty before checking again.pauseTimeInMillis - the pauseTimeInMillis to setCopyright © 2010-2011. All Rights Reserved.