Q - queue item typeT - the type of queue item that this reader can convertR - the result of processing the converted messagepublic class QueueReader<Q,T,R> extends ExceptingRunnable
MessageQueueReader| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_SLEEP_MS
default sleep time in ms between idle queue reads
|
protected java.util.concurrent.ExecutorService |
executor |
protected QueueItemHandler<Q,T,R> |
handler |
protected java.lang.Iterable<java.util.Collection<Q>> |
queueItemProvider |
protected long |
sleepMs |
| Constructor and Description |
|---|
QueueReader(java.lang.Iterable<java.util.Collection<Q>> provider,
QueueItemHandler<Q,T,R> handler,
java.util.concurrent.ExecutorService executor)
Construct a new MessageQueueReader with the default idle timeout.
|
QueueReader(java.lang.Iterable<java.util.Collection<Q>> provider,
QueueItemHandler<Q,T,R> handler,
java.util.concurrent.ExecutorService executor,
long sleepMs)
Construct a new MessageQueueReader with the given timeout.
|
| Modifier and Type | Method and Description |
|---|---|
void |
go() |
runpublic static final long DEFAULT_SLEEP_MS
protected java.lang.Iterable<java.util.Collection<Q>> queueItemProvider
protected QueueItemHandler<Q,T,R> handler
protected java.util.concurrent.ExecutorService executor
protected long sleepMs
public QueueReader(java.lang.Iterable<java.util.Collection<Q>> provider, QueueItemHandler<Q,T,R> handler, java.util.concurrent.ExecutorService executor)
provider - provider to endlessly pull messages fromhandler - handler implementation to convert and process messagesexecutor - executor service used for forking message handler processingpublic QueueReader(java.lang.Iterable<java.util.Collection<Q>> provider, QueueItemHandler<Q,T,R> handler, java.util.concurrent.ExecutorService executor, long sleepMs)
provider - provider to endlessly pull messages fromhandler - handler implementation to convert and process messagesexecutor - executor service used for forking message handler processingsleepMs - how long to sleep in ms between reads from the queue where no messages are returnedpublic void go()
throws java.lang.Exception
go in class ExceptingRunnablejava.lang.Exception