Spring Cloud Stream: spring.cloud.stream.default.consumer.concurrency property exactly meaning

为君一笑 提交于 2020-07-21 07:06:37

问题


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

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?

Thanks!


回答1:


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.



来源:https://stackoverflow.com/questions/54260536/spring-cloud-stream-spring-cloud-stream-default-consumer-concurrency-property-e

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