Kafka对接HBase

public class HBaseConsumer {
    public static void main(String[] args) {
   		 //加载配置信息
        KafkaConsumer kafkaConsumer = new KafkaConsumer<>(PropertiesUtil.properties);
        //消费kafka.topics
        kafkaConsumer.subscribe(Arrays.asList(PropertiesUtil.getProperty("kafka.topics")));

        HBaseDAO hd = new HBaseDAO();
        while (true){
        	//拉消息过来
            ConsumerRecords records = kafkaConsumer.poll(100);
            //遍历你拉的消息
            for (ConsumerRecord cr: records) {
                String ori = cr.value();
                System.out.println(ori);
                //17269452013,15542823911,2018-08-28 11:58:23,0800
                hd.put(ori);
            }
        }
    }
}

你可能感兴趣的:(我的项目实战)