Setup

pip install kinesis-python

Producer and Consumer

Producer The producer works by launching a single process for accumulation and publishing to the stream.

from kinesis.producer import KinesisProducer
 
producer = KinesisProducer(stream_name='my-stream')
producer.put('Hello World from Python')

Consumer

The consumer works by launching a process per shard in the stream and then implementing the Python iterator protocol.

from kinesis.consumer import KinesisConsumer
 
consumer = KinesisConsumer(stream_name='my-stream')
for message in consumer:
    print "Received message: {0}".format(message)

Credentials and Permissions

By default the producer, consumer & state classes all use the default boto3 credentials chain https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#configuring-credentials

 
python_kinesis.txt · Last modified: 2019/07/24 00:35 by root
 
RSS - 200 © CrosswireDigitialMedia Ltd