基于spring-kafka进行封装,支持原生配置,支持多数据源配置。
Kafka-spring-boot-starter 除了支持原生 spring-kafka 配置外,还增加了多数据源配置。
QQ:908942659 ; wechat:xin2014555
<dependency>
<groupId>io.github.pg-liudong</groupId>
<artifactId>kafka-spring-boot-starter</artifactId>
<version>1.0.5</version>
</dependency>
- 支持原生:支持spring-kafka原生配置。
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
- 支持多数据源:支持多数据源配置。(配置粒度越小,优先级越高,遵循就近原则)
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
如果觉得插件很赞,为你节约了不少时间,那么就请作者喝杯咖啡吧~☕☕☕,非常感谢!
不定期分享编程技术干货笔记,不限于算法、数据库、Spring Boot、微服务、高并发、JVM、Docker、ELK、编程技巧等相关知识,期待与您共同进步!