fix:refactor the project and optimize the configuration loading method
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.zdjizhi.utils.connections.kafka;
|
||||
|
||||
import org.apache.flink.api.common.serialization.SimpleStringSchema;
|
||||
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
public class KafkaProducer {
|
||||
|
||||
public static FlinkKafkaProducer<String> getKafkaProducer(String topic, Properties Properties){
|
||||
FlinkKafkaProducer<String> kafkaProducer = new FlinkKafkaProducer<>(
|
||||
topic,
|
||||
new SimpleStringSchema(),
|
||||
Properties,
|
||||
Optional.empty()
|
||||
);
|
||||
kafkaProducer.setLogFailuresOnly(true);
|
||||
|
||||
return kafkaProducer;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user