2013-12-19 159 views
0

在下面的示例中,如果我已經知道它是插入數據時返回的序列號,則可以返回該記錄。 但是,如何返回已由不同設備添加的所有數據?方法不會返回最新記錄

import boto 
mykin = boto.connect_kinesis(aws_access_key_id='access_key', 
          aws_secret_access_key='secret_key') 
myput = mykin.put_record(stream_name='mytest', data='abcdefghij', 
         partition_key='parti11', b64_encode=True) 
myiterator = mykin.get_shard_iterator(stream_name='mytest', 
             shard_id='shardId-000000000000', 
             shard_iterator_type='AT_SEQUENCE_NUMBER', 
             starting_sequence_number= 
             myput['SequenceNumber']) 
mykin.get_records(shard_iterator=myiterator['ShardIterator']) 
+0

你找到了一個解決方案? – aliirz

回答

1

在製作:

kinesis = boto.kinesis.connect_to_region('us-east-1', aws_access_key_id, aws_secret_access_key) 
response = kinesis.describe_stream('stream_name') 
shard_id = response['StreamDescription']['Shards'][0]['ShardId'] 
response = kinesis.get_shard_iterator('stream_name', shard_id, 'TRIM_HORIZON')