首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

kafka系列--消费

public String title;     public  ConsumerRecords<byte[], byte[]> records;     public KafkaConsumerSimple(String title, ConsumerRecords<byte[], byte[]> records) {         this.title = title;         this.records = records;     }     @Override     public void run() {         System.out.println("开始运行 " + title);         for (ConsumerRecord<byte[], byte[]> record : records) {             if(record!=null){                 String topic = record.topic();                 int partition = record.partition();                 long offset = record.offset();                 String msg = new String(record.value());                 String key=new String(record.key());                 //System.out.println(String.format(                         "Consumer: [%s],  Topic: [%s],  PartitionId: [%d], Offset: [%d], msg: [%s],key:[%s]",                         title, topic, partition, offset, msg,key));             }         }         //System.out.println(String.format("Consumer: [%s] exiting ...", title));     }     public static void main(String[] args) {         Properties properties = new Properties();

01
领券