Concurrency

对反应式 Kafka 绑定程序使用反应式函数时,如果在 consumer 绑定上设置并发,那么绑定程序就创建与并发值提供的相同数量的专用 KafkaReceiver 对象。换句话说,这会创建具有独立 Flux 实现的多个反应式流。当从分区主题使用记录时,这可能会很有用。

When using reactive functions with the reactive Kafka binder, if you set concurrency on the consumer binding, then the binder creates as many dedicated KafkaReceiver objects as provided by the concurrency value. In other words, this creates multiple reactive streams with separate Flux implementations. This could be useful when you are consuming records from a partitioned topic.

例如,假设传入主题至少有三个分区。然后可以设置以下属性。

For example, assume that the incoming topic has at least three partitions. Then you can set the following property.

spring.cloud.stream.bindings.lowercase-in-0.consumer.concurrency=3

这会创建三个专用 KafkaReceiver 对象,这些对象生成三个独立的 Flux 实现,然后将它们流式传输到处理程序方法。

That will create three dedicated KafkaReceiver objects that generate three separate Flux implementations and then stream them to the handler method.