|
@ -12,6 +12,8 @@ import java.util.Properties;
|
12
|
12
|
public class KafkaCustomerExample {
|
13
|
13
|
private static final Log logger = LogFactory.getLog(KafkaCustomerExample.class);
|
14
|
14
|
|
|
15
|
private static final int PULL_NUM = 100;
|
|
16
|
|
15
|
17
|
public static void main(String[] args) throws InterruptedException {
|
16
|
18
|
Properties properties = new Properties();
|
17
|
19
|
properties.put("bootstrap.servers", "47.105.160.21:9091,47.105.160.21:9092,47.105.160.21:9093");
|
|
@ -25,7 +27,7 @@ public class KafkaCustomerExample {
|
25
|
27
|
kafkaConsumer.subscribe(Arrays.asList("test"));
|
26
|
28
|
try {
|
27
|
29
|
while (true) {
|
28
|
|
ConsumerRecords<String, String> records = kafkaConsumer.poll(100);
|
|
30
|
ConsumerRecords<String, String> records = kafkaConsumer.poll(PULL_NUM);
|
29
|
31
|
for (ConsumerRecord<String, String> record : records) {
|
30
|
32
|
logger.debug("offset = " + record.offset() + ", value = " + record.value());
|
31
|
33
|
logger.debug("\n=================================");
|