背景:Kafka监听数据库中配置topic数据,并将数据转换后进行kafka数据转发
1.application.yml
test:
kafka:
bootstrapServers: 127.0.0.1:9092,127.0.0.1:9093
consumer:
group.id: group-id
auto.offset.reset: latest
enable.auto.commit: true
producer:
max.in.flight.requests.per.connection: 1
acks: -1
buffer.memory: 33554432
batch.size: 16384
linger.ms: 100
retries: 1
2.KafkaConfig.java
@Component
@ConfigurationProperties(prefix = "test.kafka")
@Data
@Slf4j
public class KafkaConfig implements InitializingBean {
private String bootstrapServers;
private Properties consumer;
private Properties producer;
@Override
public void afterPropertiesSet() throws Exception {
Properties consumerProperties = getConsumerProperties();
Properties producerProperties = getProducerProperties();
}
public Properties getConsumerProperties(

本文介绍如何在Java应用中通过配置文件(application.yml)设置Kafka监听数据库中的topic信息,接收数据后进行转换,再将转换后的数据转发到Kafka。
最低0.47元/天 解锁文章
675

被折叠的 条评论
为什么被折叠?



