Encapsulation based on spring-kafka not only supports native configuration, but also adds multi data source configuration.
Kafka-spring-boot-starter is encapsulated based on spring-kafka. In addition to supporting native configuration, it also adds multi data source configuration.
QQ:908942659 ; wechat:xin2014555
<dependency>
<groupId>io.github.pg-liudong</groupId>
<artifactId>kafka-spring-boot-starter</artifactId>
<version>1.0.5</version>
</dependency>
- Support native: Support spring-kafka native configuration.
spring:
kafka:
bootstrap-servers: localhost:9092
consumer:
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
auto-offset-reset: earliest
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
- Support multiple data sources: Support multi data source configuration.(The smaller the configuration granularity, the higher the priority)
spring:
kafka:
multiple:
# Primary data source is not allowed to be empty.
primary: ds1
consumer:
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
auto-offset-reset: latest
producer:
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
datasource:
ds1:
bootstrap-servers: localhost:9092
consumer:
# Consumer concurrent kafka listener container factory is not allowed to be empty.
container-factory: ds1KafkaListenerContainerFactory
auto-offset-reset: earliest
producer:
kafka-template: ds1KafkaTemplate
ds2:
bootstrap-servers: localhost:9093
consumer:
container-factory: ds2KafkaListenerContainerFactory
auto-offset-reset: earliest
producer:
# Producer kafka template bean name is not allowed to be empty.
kafka-template: ds2KafkaTemplate
If you think the plug-in is great and saves you a lot of time, invite the author to have a cup of coffee~ ☕☕☕, Thank you. Your support is the driving force to encourage us to move forward. No matter how much it is, it is enough to express your intention.
Irregularly share the dry notes of programming technology, not limited to algorithms, databases, spring boot, microservices, high concurrency, JVM, docker, elk, programming skills and other related knowledge. We look forward to making progress with you!