Processing empty records from getRecords
operations is more efficient by setting withCallProcessRecordsEvenForEmptyRecordList
to TRUE
during Kinesis Client Library (KCL) initialization. This will allow for differentiation of empty records so that they may be treated differently.
1public KinesisClientLibConfiguration configureKCLNoncompliant() {
2 // Noncompliant: doesn't set withCallProcessRecordsEvenForEmptyRecordList to true during Kinesis Client Library (KCL) initialization.
3 KinesisClientLibConfiguration kclConfig = new KinesisClientLibConfiguration(applicationName,
4 streamARN, ddbStreamCredentials, workerID)
5 .withMaxRecords(maxRecords)
6 .withIdleTimeBetweenReadsInMillis(idleTimeBetweenReadsInMillis)
7 .withFailoverTimeMillis(leaseFailOverTimeInMillis)
8 .withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON);
9 return kclConfig;
10}
1public KinesisClientLibConfiguration configureKCLCompliant() {
2 // Compliant: sets withCallProcessRecordsEvenForEmptyRecordList to true during Kinesis Client Library (KCL) initialization.
3 KinesisClientLibConfiguration kclConfig = new KinesisClientLibConfiguration(applicationName,
4 streamARN, ddbStreamCredentials, workerID)
5 .withMaxRecords(maxRecords)
6 .withCallProcessRecordsEvenForEmptyRecordList(true)
7 .withIdleTimeBetweenReadsInMillis(idleTimeBetweenReadsInMillis)
8 .withFailoverTimeMillis(leaseFailOverTimeInMillis)
9 .withInitialPositionInStream(InitialPositionInStream.TRIM_HORIZON);
10 return kclConfig;
11}