Spring Cloud Stream Kafka consumer patterns

Ajay

For a topic with multiple partitions -

1) Does a single SpringBoot instance use multiple threads to process (method annotated with StreamListener) each message from each partition?

2) Is it possible to configure more than one thread for each partition or is that something I would have to manually hand off from my listener thread to a worker pool?

Gary Russell

....consumer.concurrency controls the number of threads (default 1).

The partitions are distributed across the threads. If you have 20 partitions and 4 threads; they'll get 5 partitions each.

You need to have at least as many partitions as the aggregate concurrency across all instances. (If you have 2 app instances and 5 threads each, you need at least 10 partitions).

You should not distribute messages from a single partition across multiple threads; the offset will be committed as soon as you hand off to the new thread and that could cause message loss.

You should always err on the side of having more partitions than you need concurrency.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Auto commit in kafka with spring cloud stream

Spring Cloud Stream (Hoxton) Kafka Producer / Consumer not working in integration tests with EmbeddedKafka

Spring Cloud Stream Kafka - Method must be Declarative

Spring cloud stream and consume multiple kafka topics

spring-cloud-stream kafka offline consumer messages lost

Correctly manage DLQ in Spring Cloud Stream Kafka

Spring Cloud Stream embedded header format (Kafka)

Error Handling in Spring Cloud Stream - Kafka Binder

Multiple StreamListeners with Spring Cloud Stream connected to Kafka

Multiple @EnableBinding with Kafka Spring Cloud Stream

How to implement a Kafka consumer to process events on demand using spring-cloud-stream?

Spring Cloud Stream for Kafka with consumer/producer API exactly once semantics with transaction-id-prefix is not working as expected

Understanding Spring Cloud Stream Kafka and Spring Retry

Spring cloud stream with kafka streams binder: how to set `trusted.packages` for a Stream Processor (that's different than consumer and producer)

Spring cloud stream - Kafka binder performance

Spring Cloud Stream Kafka Error channel

Spring Cloud Stream Kafka Consumer Test

spring cloud stream kafka binding config

Abstracting Spring Cloud Stream Producer and Consumer code

Kafka - spring cloud stream

Spring cloud stream (Kafka) autoCreateTopics not working

Spring Cloud Stream Kafka-Streams unable to configure SSL for my consumer and producer

Kafka Sticky Partitioner using spring cloud stream

Override retry attempts with spring cloud stream kafka bindings consumer and DLQ enabled

Spring Cloud Stream consumer startup

Spring Cloud Stream: consumer for different message types

How to tell if every consumer finished in Spring Cloud Stream Kafka?

Batch Consumer not working with Kafka for CloudEvents using Spring Cloud Stream

Spring Cloud Kafka Consumer Properties not working