public class KinesisClientLibraryPipelinedRecordProcessor extends Object implements com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessor
Wraps an IRecordProcessor to pipeline fetching and processing records.
This decouples reading from a stream and processing the records retrieved from the stream. This is useful when either GetRecords or ProcessRecords calls take significant time (e.g. cross-region calls, long-lived tasks, etc). By separating the functionality, the total throughput of the application becomes limited by max(time(GetRecords), time(ProcessRecords)) rather than time(GetRecords) + time(ProcessRecords).
The processRecords method fills a bounded-size, blocking queue with the records to bound the amount of memory required for the record processor. A separate
thread consumes the queue and passes batches of records to the wrapped IRecordProcessor.
The IRecordProcessor must checkpoint using the IRecordProcessorCheckpointer.checkpoint(String) method with a specific sequence number.
Checkpointing using IRecordProcessorCheckpointer.checkpoint() may only be used in
IRecordProcessor.shutdown(IRecordProcessorCheckpointer, ShutdownReason). Using IRecordProcessorCheckpointer.checkpoint() in processRecords
will result in an UnsupportedOperationException.
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_MAXIMUM_PROCESS_RECORDS_WAIT_TIME_MS
Default maximum time to wait for the queue consumer to shutdown (finish ProcessRecords call).
|
static long |
DEFAULT_MAXIMUM_QUEUE_WAIT_TIME_MS
Default maximum time to block on the queue waiting for GetRecords result.
|
| Constructor and Description |
|---|
KinesisClientLibraryPipelinedRecordProcessor(com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessor recordProcessor,
int maxQueueSize)
Constructor.
|
KinesisClientLibraryPipelinedRecordProcessor(com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessor recordProcessor,
int maxQueueSize,
Long maxQueueWaitTimeMs,
Long maxProcessRecordsWaitTimeMs)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
initialize(String shardId) |
void |
processRecords(List<com.amazonaws.services.kinesis.model.Record> records,
com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer checkpointer) |
void |
shutdown(com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer checkpointer,
com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShutdownReason reason) |
public static final long DEFAULT_MAXIMUM_QUEUE_WAIT_TIME_MS
public static final long DEFAULT_MAXIMUM_PROCESS_RECORDS_WAIT_TIME_MS
public KinesisClientLibraryPipelinedRecordProcessor(com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessor recordProcessor,
int maxQueueSize)
recordProcessor - The record processor to wrapmaxQueueSize - The maximum queue sizepublic KinesisClientLibraryPipelinedRecordProcessor(com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessor recordProcessor,
int maxQueueSize,
Long maxQueueWaitTimeMs,
Long maxProcessRecordsWaitTimeMs)
recordProcessor - The record processor to wrapmaxQueueSize - The maximum queue sizemaxQueueWaitTimeMs - Maximum time to block on the queue waiting for GetRecords result in millisecondsmaxProcessRecordsWaitTimeMs - Maximum time to wait for the queue consumer to shutdown (finish ProcessRecords call) in millisecondspublic void initialize(String shardId)
initialize in interface com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorpublic void processRecords(List<com.amazonaws.services.kinesis.model.Record> records, com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer checkpointer)
processRecords in interface com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorpublic void shutdown(com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer checkpointer,
com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShutdownReason reason)
shutdown in interface com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCopyright © 2016. All rights reserved.