json数据入库kafka
2021-02-17
来源:好走旅游网
json数据⼊库kafka
package main.scala.com.web.zhangyong168.cn.spark.java;import com.alibaba.fastjson.JSONObject;
import com.web.zhangyong168.cn.spark.util.PropertiesUtils;import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.KafkaAdminClient;import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.clients.producer.KafkaProducer;import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;import org.sparkproject.guava.collect.Lists;import java.util.*;/**
@version 1.0.0@Author zhangyong
@Description json数据⼊库kafka@Date 2020/06/05 14:40**/
public class WirteKafka {/**
配置⽂件的路径
@param proUrl 配置⽂件路径
@param runModel 运⾏模式 test dev produce
@return properties*/
public static Properties getProperties(String proUrl, String runModel) {Properties props = PropertiesUtils.loadProps(\"kafka.properties\");Properties properties = new Properties();
properties.put(\"bootstrap.servers\properties.put(\"zookeeper.connect\properties.put(\"group.id\
properties.put(\"key.serializer\properties.put(\"value.serializer\return properties;}/**
获得数据结果集
@param accessArray 参数@return list*/
public static List