Browse Source

修复sonar扫描

liutong3 4 years ago
parent
commit
66b6fb58cb

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

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