public class ProcessingQueue<T> extends SimpleLogSupportAdapter
LinkedBlockingDeque
with an internal attached processing daemon thread.
The thread takes entries off the queue and passes them to the QueueHandler
for processing.Constructor and Description |
---|
ProcessingQueue(LogChannel logCh,
java.lang.String queueName) |
ProcessingQueue(LogChannel logCh,
java.lang.String queueName,
QueueHandler queueHandler) |
ProcessingQueue(LogChannel logCh,
java.lang.String queueName,
QueueHandler queueHandler,
int capacity) |
Modifier and Type | Method and Description |
---|---|
void |
awaitAllDelivered(long time,
java.util.concurrent.TimeUnit unit)
Waits until all current entries of the queue have been delivered and processed.
|
java.lang.String |
getName() |
int |
put(T entry)
Puts an entry at the end of the queue.
|
int |
putUrgent(T entry)
Puts an urgent entry on top of the queue.
|
void |
setHandler(QueueHandler handler)
Sets the
QueueHandler which processes every entry taken from the queue. |
void |
setPutTimeout(int timeoutSeconds)
Defines a timeout for put operations in seconds.
|
void |
shutdown()
Delivers all entries of the queue and kills the running daemon thread.
|
int |
size() |
getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString
public ProcessingQueue(LogChannel logCh, java.lang.String queueName)
public ProcessingQueue(LogChannel logCh, java.lang.String queueName, QueueHandler queueHandler)
public ProcessingQueue(LogChannel logCh, java.lang.String queueName, QueueHandler queueHandler, int capacity)
public java.lang.String getName()
public int size()
public void setPutTimeout(int timeoutSeconds)
public void setHandler(QueueHandler handler)
QueueHandler
which processes every entry taken from the queue.
Note that the queue starts automatically if the handler is set. It stops, when
the handler is set to null or shutdown()
is called.public void shutdown()
QueueHandler
is nullified on shutdown.
Setting a new handler will restart the queue daemon thread.public int putUrgent(T entry) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.util.concurrent.TimeoutException
java.lang.InterruptedException
public int put(T entry) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.util.concurrent.TimeoutException
java.lang.InterruptedException
public void awaitAllDelivered(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
Copyright © 2014 EsprIT-Systems. All Rights Reserved.