解决Kafka消费者启动时频繁打印⽇志环境:
SpringBoot 2.1.5.RELEASE
Kafka kafka_2.11-1.
kafka maven依赖
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
</dependency>
消费者:
public class ConsumerFastStart {
public static final String brokerList = "hadoop000:9092,hadoop001:9092,hadoop002:9092";
public static final String topic = "tests";
public static void main(String[] args) {
Properties properties = new Properties();
properties.put("key.deserializer", Name());
properties.put("value.deserializer", Name());
properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList);
properties.put("group.id", args[0]);
properties是什么文件KafkaConsumer<String, String> consumer = new KafkaConsumer<>(properties);
consumer.subscribe(Collections.singletonList(topic));
php小说阅读器while (true){
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(1000));
for (ConsumerRecord<String, String> record : records) {
System.out.println(record.value());
}
}
}
}
⽣产者:
public class ProducerFastStart {
public static final String brokerList = "hadoop000:9092,hadoop001:9092,hadoop002:9092";
public static final String topic = "tests";
public static void main(String[] args) {
Properties properties = new Properties();
properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, Name());
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, Name());
properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, brokerList);
//抛出可重试异常,设置重试次数
properties.put(ProducerConfig.RETRIES_CONFIG, 10);
安卓开发小项目KafkaProducer<String, String> producer = new KafkaProducer<>(properties);
ProducerRecord<String, String> record = new ProducerRecord<>(topic, "Hello, world!");
try {
producer.send(record);
房地产网站cms} catch (Exception e) {
e.printStackTrace();
} finally {
producer.close();
}
}
}
问题分析access设计数据库步骤
我在百度这个问题时,很多⼈都说添加⼀段⽇志配置到log4j.properties中,但是⼀直没⽣效。我查看了maven依赖到了logback-classic。
我想应该配置的是l
哪种编程语言应用最广泛1.创建l
2.添加xml配置
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<logger name="org.apache.kafka.clients" level="info" />
</configuration>
3.重启⽣产者没有⽇志输出,问题解决。
有缘⼈,希望能帮助你解决这个问题。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。