[英]Spring Cloud Stream Kinesis Binder - Concurrency
我用以下组件构建了一个弹簧启动运动消费者:
我消耗了具有1个分片的运动流中的事件。 同样,该春季启动用户应用程序也在Pivotal Cloud Foundry Platform中运行。
在发布此问题之前,我在本地(使用Kinesalite)和PCF(使用运动学流)中尝试了该方案。 您能否确认我的理解是否正确? 我浏览了Spring Cloud Stream文档( https://docs.spring.io/spring-cloud-stream/docs/current/reference/htmlsingle/和https://github.com/spring-cloud/spring-cloud- stream-binder-aws-kinesis / blob / master / spring-cloud-stream-binder-kinesis-docs / src / main / asciidoc / overview.adoc )。 尽管文档详尽无遗,但并未详细解释并发性和高可用性。
假设我有3个消费者实例部署到PCF(通过在cf push期间使用的manifest.yml文件中将instances属性设置为3)。
所有3个实例均具有以下属性 :
spring.cloud.stream.bindings..consumer.concurrency = 5
spring.cloud.stream.bindings..group =我的消费者组
spring.cloud.stream.kinesis.binder.checkpoint.table =我的元数据动态模型表
spring.cloud.stream.kinesis.binder.locks.table = my-locks-dynamodb-table
假设事件是由生产者按此顺序发送给运动机
event5(流中的最新事件)-event4-event3-event2-event1(流中的第一个事件)
对于这种配置,我在下面解释了我的理解。 您可以确认这是否正确吗?
请在KinesisMessageDrivenChannelAdapter
查看concurrency
选项JavaDocs:
/**
* The maximum number of concurrent {@link ConsumerInvoker}s running.
* The {@link ShardConsumer}s are evenly distributed between {@link ConsumerInvoker}s.
* Messages from within the same shard will be processed sequentially.
* In other words each shard is tied with the particular thread.
* By default the concurrency is unlimited and shard
* is processed in the {@link #consumerExecutor} directly.
* @param concurrency the concurrency maximum number
*/
public void setConcurrency(int concurrency) {
因此,由于在一个流中只有一个分片,所以将只有一个活动线程在该单个分片上的ShardIterator
上进行迭代。
关键是我们总是必须在单个线程中处理单个碎片中的记录。 这样,我们保证顺序正确,并为最高的序列号加上了检查点。
请进一步研究什么是AWS Kinesis及其工作方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.