Amazon-Kinesis: Put record to every shard

做~自己de王妃 提交于 2019-12-12 17:03:48

问题


I have an Amazon Kinesis stream, consisting of multiple shards. The number of shards, and therefore the number of consumers, is not a constant.

There is an infrequent type of event that I want broadcasted to every consumer on the stream.

Is there a way for a producer to broadcast a record, i.e. to discover the shards and put the record on each one?


回答1:


You can do this! Kind of...

The trick it to use the parameter "ExplicitHashKey".

This lets you set the hash key used for the record, and therefore lets you chose what shard your data is going on.

You can then call

aws kinesis describe-stream --stream-name name-of-your-stream

to get info about each shard including what hash range each shard covers.

Then you only need to send your data to each shard (with PutRecord or PutRecords) and you are all set.

Unfortunately, there is no "broadcast" but you can easily write a Lambda to send the same data to each shard using the ExplicitHashKey parameter.

Another solution is to use separate streams and write out to each one.



来源:https://stackoverflow.com/questions/34883551/amazon-kinesis-put-record-to-every-shard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!