-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete data retrieved. #5
Comments
Mmh this is weird, I haven't seen this issue yet, have you tried using different horizons? |
Hi Federico, I've found a solution to this. Instead of getting records by only the first shard iterator, an application should continuously use the // Initialize the shard iterators.
val initialShardIteratorsRequest = for {
shards <- stream.get.shards.list
initialShardIterator <- Future.sequence(shards.map {
shard => implicitExecute(shard.iterator)
})
} yield initialShardIterator
var shardIterators = Await.result(initialShardIteratorsRequest,
30.seconds).asInstanceOf[List[ShardIterator]]
// Continuously poll for records.
while (shardIterators != null) {
val recordChunksRequest = for {
recordChunkIterator <- Future.sequence(shardIterators.map {
iterator => implicitExecute(iterator.nextRecords)
})
} yield recordChunkIterator
val recordChunks = Await.result(recordChunksRequest, 30.seconds)
//println("recordChunks: " + recordChunks.toString)
val nextShardIterators = new MutableList[ShardIterator]()
for (recordChunk <- recordChunks) {
//println("==Record chunk:" + recordChunk.toString)
for (record <- recordChunk.records) {
println("sequenceNumber: " + record.sequenceNumber)
//printData(record.data.array())
println("partitionKey: " + record.partitionKey)
}
nextShardIterators += recordChunk.nextIterator
}
shardIterators = nextShardIterators.toList
Thread.sleep(1000)
} |
Hi Federico,
I've modified your example to add 10 items to Kinesis and then attempt to retrieve them 10 separate times to illustrate a bug I'm seeing in some of my other projects where not all of the records are retrieved:
Do you know if this is expected behavior from Kinesis?
Am I doing something subtly wrong when retrieving the data?
Below, some attempts retrieve all 10 records, but other attempts, such as the last one, read less than 10 records.
The text was updated successfully, but these errors were encountered: