赞
踩
//生产者
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
public class FileToKafka {
// private KafkaProducer<String,String> producer;
private KafkaProducer<String,byte[]> producer;
private Properties properties;
public FileToKafka() {
properties = new Properties();
properties.put("bootstrap.servers", "master:9092,master:9093");
properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
properties.put("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer");
// producer = new KafkaProducer<String, String>(properties);
producer = new KafkaProducer<String, byte[]>(properties);
}
// public void sendRecorder(String key,String value) {
// ProducerRecord<String, Stri
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。