Kinesis GetRecords API返回空的Records []数组

时间:2019-05-02 20:10:21

标签: python-3.x boto3 amazon-kinesis

我正在尝试使用aws-kinesis get_records读取记录,但是它返回空array []记录。

在任何地方都找不到明确的解决方案。

我尝试通过设置适当的必需凭据来使用CLIBoto3

我测试了2个流程:

  1. 创建的流->使用put_record->插入记录,并基于迭代器使用get_records读取记录,效果非常好!但是

  2. 当我尝试直接使用get_records读取记录时。返回空数组[]。

aws kinesis describe-stream --stream-name TestDataStream

```get shard iterator
aws kinesis get-shard-iterator --stream-name TestDataStream --shard-id shardId-000000000000 --shard-iterator-type LATEST

```get-records
aws kinesis get-records --shard-iterator xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

```RESULT - empty 
{
    "Records": [], 
    "NextShardIterator": "AAAAAAAAAAGpDl4WXIHlx3gGq52/EDxEG5CkQU57gf/tR9W+6Gm2KWCCDp8baoE+Basz0OENMdQFhRCQp/cwp0pVMA8CtGwd+WdfXeIucK6d83Vc+DzIAnw/DGqQ4nJSRcFJg3za5+eAHm9hH781vSEYa0ivcbgfhjskudkugd/phhnb9gVJQRyGfNmAVli+htmQkZwYgaTji05M4r9C9RKVn+c49E2rZ8D", 
    "MillisBehindLatest": 0
}



```PYTHON CODE

client = boto3.client('kinesis', aws_access_key_id='xxxxxxx',
                              aws_secret_access_key='xxxxxxx/',
                              region_name='us-east-1')
        streamName = "TestDataStream"
        response = client.describe_stream(StreamName=streamName)
        print("::stream description::", response)
        my_shard_id = response['StreamDescription']['Shards'][0]['ShardId']
        shard_iterator = client.get_shard_iterator(StreamName=streamName,
                                                   ShardId=my_shard_id,
                                                   ShardIteratorType='TRIM_HORIZON')
        my_shard_iterator = shard_iterator['ShardIterator']
        print("::shard_iterator::", my_shard_iterator)
        record_response = client.get_records(ShardIterator=my_shard_iterator,
                                                 Limit=30)
        print(":: Records ::", record_response)

0 个答案:

没有答案