Java向kafka发送数据(demo)
测试环境:Win10安装kafka步骤
package com.klay.utils;
import java.util.Properties;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
public class SendDataToKafka {
public static void main(String[] args) {
SendDataToKafka sendDataToKafka = new SendDataToKafka();
sendDataToKafka.send("test_topic", "", "this is a test data too");
}
public void send(String topic, String key, String data) {
共有 0 条评论