Spring Cloud Stream:spring.cloud.stream.default.consumer.concurrency 属性的确切含义 [英] Spring Cloud Stream: spring.cloud.stream.default.consumer.concurrency property exactly meaning

查看:31
本文介绍了Spring Cloud Stream:spring.cloud.stream.default.consumer.concurrency 属性的确切含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道使用 spring.cloud.stream.default.consumer.concurrency 属性时并发"的确切含义.

I would like to know the exactly meaning of "concurrency" when using spring.cloud.stream.default.consumer.concurrency property.

文档(https:///docs.spring.io/spring-cloud-stream/docs/Chelsea.RELEASE/reference/html/_configuration_options.html) 说入站消费者的并发性",这可以有多种解释.

Documentation (https://docs.spring.io/spring-cloud-stream/docs/Chelsea.RELEASE/reference/html/_configuration_options.html) says "The concurrency of the inbound consumer" and this can be interpreted in several ways.

幕后创建了什么样的线程执行器?

What kind of thread executor is created behind the scenes?

谢谢!

推荐答案

并发的语义取决于实际的绑定器实现.例如,在 Kafka 绑定器的情况下,当您设置并发时,该值将传递到底层 MessageListenerContainer.假设您的消费者应用程序正在从一个具有 3 个分区的主题进行消费,并且您将 concurrency 的值设置为 3.这将通过容器创建 3 个线程,每个线程在其中处理单个分区从主题(实际上,在 Kafka binder 的情况下,会在幕后创建 3 个侦听器容器).如果主题上的分区多于并发线程数,则分区将分布在各个线程上.同样的语义也适用于 Rabbit 绑定器,尽管它的实际实现在内部可能略有不同.

The semantics of concurrency is dependent on the actual binder implementation. For example in the case of the Kafka binder, when you set concurrency, that value will be passed on to the underlying MessageListenerContainer. Lets say that your consumer application is consuming from a topic that has 3 partitions and you set the value of concurrency to 3. This will create 3 threads by the container in which each of them is handling a single partition from the topic (In fact, in the case of Kafka binder, 3 listener containers will be created behind the scenes). If there are more partitions on the topic than there are concurrent threads, then the partitions will be distributed across the various threads. The same semantics apply for the Rabbit binder as well although the actual implementation of it may vary slightly internally.

这篇关于Spring Cloud Stream:spring.cloud.stream.default.consumer.concurrency 属性的确切含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆