Search code examples
multithreadingspring-bootapache-kafkaspring-kafkaspring-transactions

Multi thread transactional Kafka producer and consumer with Spring Boot


I have a project which uses Spring Boot related project. I want to use the Transactional feature of Kafka consumer and producer in the project. I need to produce a lot of messages in Kafka as efficient as possible. So I need a multi-thread consuming and producing for this requirement. How can I use Spring boot for developing a multi-thread consumer and producer?


Solution

  • See the concurrency listener Boot property.

    spring.kafka.listener.concurrency
    

    The topic must have at least as many partitions as the concurrency.

    https://docs.spring.io/spring-kafka/docs/2.6.1/reference/html/#message-listener-container