Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws kinesis get-records returns empty array

I am playing around with Kinesis, and I tried a very simple example

I first put a sample record

aws kinesis put-records --records "Data=Test data - hemant,PartitionKey=20150421" --stream-name mystream 

I get back

{
"FailedRecordCount": 0,
"Records": [
    {
        "SequenceNumber": "49549975503580743304507290523786194552567002802960728066",
        "ShardId": "shardId-000000000000"
    }
]}

So put appears to have worked. Now I am trying to retrive back this record, first, by getting the shard-iterator, and then calling the gert-record using the returned shard-iterator. The get-shard-iterator returns

aws kinesis get-shard-iterator --stream-name cakestream --shard-id 0 --shard-iterator-type LATEST
{
"ShardIterator": "AAAAAAAAAAEna1yL0ccbircK95wu6WRfN7LamlaXL5bZ1GzaFrUcSU8S74o4Pus59Z0XmdaMamdvz4tv3qKuPxpomz/Eeg671gVUKNHUDruAKyA4pjWRP37VI1K5w/kLqpBo49YsCKHMxcduaN6GdeCXL4QMSgvH9Aqi7leRuIr2T1w4MeqjhlcM1iz8icaWGlHfUVCbgtY="}

And now I try to get the records using that shard-iterator

aws kinesis get-records --shard-iterator "AAAAAAAAAAEna1yL0ccbircK95wu6WRfN7LamlaXL5bZ1GzaFrUcSU8S74o4Pus59Z0XmdaMamdvz4tv3qKuPxpomz/Eeg671gVUKNHUDruAKyA4pjWRP37VI1K5w/kLqpBo49YsCKHMxcduaN6GdeCXL4QMSgvH9Aqi7leRuIr2T1w4MeqjhlcM1iz8icaWGlHfUVCbgtY="{
"NextShardIterator": "AAAAAAAAAAE4lTq/jqanuj+xsULhl6QQeykzToObYDoaukearHkQfed/keYjgxzwfxkDXlBJBAOVLsk3pI9d0EwQWn5NmJ9poCL9M1wGDe2M42fgmp1EdK0WJGI1zG7TMi8m1bGQ6qDL05zf7gCtK5/xod6Vw/Gr98bsdQ8Ewp3U57FuHxZ29LUUbYp3AoN7CbUTD5rtqzU=",
"Records": []}

So, my question is why am I not getting back my data?

like image 987
Hemant Avatar asked Apr 22 '15 16:04

Hemant


2 Answers

The LATEST shard iterator will return all records put into the stream after it was created.

So, if you'd like to see your records, you'll have to put them after you create the iterator, and then request for get-records.

like image 82
Paedolos Avatar answered Oct 23 '22 18:10

Paedolos


As Paedolos mentioned, LATEST shard iterator will return only the records put after the iterator is created.

If you would like to process all the records in the stream from beginning, you need to create TRIM_HORIZON shard iterator.

like image 2
Karthikeyan Marudhachalam Avatar answered Oct 23 '22 18:10

Karthikeyan Marudhachalam