Commit 77836bcf by lichaomin

测试类格式

parent 91204328
...@@ -17,11 +17,12 @@ public class TestProducer { ...@@ -17,11 +17,12 @@ public class TestProducer {
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
KafkaProducer producer = new KafkaProducer<String, String>(props); KafkaProducer producer = new KafkaProducer<String, String>(props);
for (int i = 1; i <= 20; i++) { for (int i = 1; i <= 200; i++) {
String student = "{l_" + (i % 10) + ": " + i + "}"; String student = "{name:l_" + (i % 10) + ",sale: " + i + "}";
ProducerRecord record = new ProducerRecord<String, String>(topic, null, null, student); ProducerRecord record = new ProducerRecord<String, String>(topic, null, null, student);
producer.send(record); producer.send(record);
System.out.println("发送数据: " + student); System.out.println("发送数据: " + student);
Thread.sleep(1000);
} }
producer.flush(); producer.flush();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment