Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goudai/spring-boot-starter-kafka
Spring boot & Spring Cloud Kafka support
https://github.com/goudai/spring-boot-starter-kafka
kafka spring-boot
Last synced: about 4 hours ago
JSON representation
Spring boot & Spring Cloud Kafka support
- Host: GitHub
- URL: https://github.com/goudai/spring-boot-starter-kafka
- Owner: goudai
- License: mit
- Created: 2017-11-10T04:31:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-11-15T23:47:06.000Z (almost 2 years ago)
- Last Synced: 2024-04-24T12:32:41.498Z (7 months ago)
- Topics: kafka, spring-boot
- Language: Java
- Homepage:
- Size: 77.1 KB
- Stars: 28
- Watchers: 5
- Forks: 16
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dependency
* kafka client 2.2.0
* spring boot
* goudai runner
# Usage## Update
* V1.0.1
1.支持故障重启,默认启用故障重启,重启间隔为20s秒默认
2.支持idea自动补全
* V1.0.2
修改groupId 发布到中央仓库
* v2.2.1
支持最新版kafka-clients(2.2.0)
## consumer* add dependency to maven
```xmlio.github.goudai
spring-boot-starter-kafka-consumer
2.2.1
```
* using on spring boot
```yaml
# application.yml
goudai:
kafka:
consumer:
bootstrap-servers: ${KAFKA_SERVERS:localhost:9092}
auto-restart:
enabled: false # 默认为true 设置为false 表示关闭故障重启
interval: 20 # 默认间隔20s
```
```java
/**
* 括号中指定group
*/
@EnableKafka("user-consumer")
public class UserConsumer {
@KafkaListener(topic = "xxx")
public void onUserRegisterCouponGranted(ConsumerRecord consumerRecord) {
System.out.println(JsonUtils.toJson(consumerRecord));
}
}```
## producer* add dependency to maven
```xml
io.github.goudai
spring-boot-starter-kafka-producer
2.2.1
```
* using on spring boot
```yaml
# application.yml
goudai:
kafka:
producer:
bootstrap-servers: ${KAFKA_SERVERS:localhost:9092}
```
```java@Component
public class UserProducer {@Autowired
Producer producer;public void sendMsg() {
producer.send(new ProducerRecord("topic","kafkaContext json"));
}
}```