Package org.jeasy.batch.core.reader
Class BlockingQueueRecordReader<P>
- java.lang.Object
-
- org.jeasy.batch.core.reader.BlockingQueueRecordReader<P>
-
- Type Parameters:
P- type of the record's payload
- All Implemented Interfaces:
RecordReader<P>
public class BlockingQueueRecordReader<P> extends java.lang.Object implements RecordReader<P>
ARecordReaderthat reads record from aBlockingQueue.- Author:
- Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_TIMEOUT
-
Constructor Summary
Constructors Constructor Description BlockingQueueRecordReader(java.util.concurrent.BlockingQueue<Record<P>> queue)Create a newBlockingQueueRecordReader.BlockingQueueRecordReader(java.util.concurrent.BlockingQueue<Record<P>> queue, long timeout)Create a newBlockingQueueRecordReader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Record<P>readRecord()Read next record from the data source.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jeasy.batch.core.reader.RecordReader
close, open
-
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final long DEFAULT_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BlockingQueueRecordReader
public BlockingQueueRecordReader(java.util.concurrent.BlockingQueue<Record<P>> queue)
Create a newBlockingQueueRecordReader.- Parameters:
queue- the queue to read records from
-
BlockingQueueRecordReader
public BlockingQueueRecordReader(java.util.concurrent.BlockingQueue<Record<P>> queue, long timeout)
Create a newBlockingQueueRecordReader.- Parameters:
queue- the queue to read records fromtimeout- in milliseconds after which the reader will returnnull
-
-
Method Detail
-
readRecord
public Record<P> readRecord() throws java.lang.Exception
Description copied from interface:RecordReaderRead next record from the data source.- Specified by:
readRecordin interfaceRecordReader<P>- Returns:
- the next record from the data source or
nullif the end of the data source is reached - Throws:
java.lang.Exception- if an error occurs during reading next record
-
-