|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.javakaffee.simplequeue.RichBDBQueue<T>
public class RichBDBQueue<T>
A wrapper around BDBQueue that provides json serialization and
blocking queue semantics.
Created on Jun 22, 2011
| Constructor Summary | |
|---|---|
RichBDBQueue(File queueBaseDir,
String queueName,
int cacheSize,
Class<T> type)
Constructs the queue using the given file for persistence. |
|
| Method Summary | |
|---|---|
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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 disk
IOException - thrown when the given file does not exist or is not writeable.| Method Detail |
|---|
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.
IOException
InterruptedExceptionpublic 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 set
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||