0%
引入依赖
1 2 3 4
| <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency>
|
消费者模式
配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| spring.kafka.consumer.bootstrap-servers=ip1:port,ip2:port
spring.kafka.consumer.enable-auto-commit=true
spring.kafka.consumer.auto-commit-interval=100ms
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.properties.session.timeout.ms=15000
spring.kafka.consumer.group-id=test-group-id
|
代码