ソースを参照

修复sonar扫描

liutong3 4 年 前
コミット
66b6fb58cb
共有1 個のファイルを変更した3 個の追加1 個の削除を含む
  1. 3 1
      comp-example/src/test/java/com/ai/ipu/example/kafka/KafkaCustomerExample.java

+ 3 - 1
comp-example/src/test/java/com/ai/ipu/example/kafka/KafkaCustomerExample.java

@ -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=================================");