小编jum*_*key的帖子

Spring Boot 2.3.2.RELEASE - Micrometer - KafkaMetrics - 无法绑定仪表日志

我正在使用/actuator/prometheus端点作为其kafka_consumer_*指标。从Spring Boot 2.3.1.RELEASEto升级,向2.3.2.RELEASE我展示了很多这些“额外”日志——每当绑定失败时:

信息 io.micrometer.core.instrument.binder.kafka.KafkaMetrics.lambda$checkAndBindMetrics$1[173] -- 无法绑定仪表:kafka.consumer.fetch.manager.[metric1]...但是,这可能发生并且可能下次刷新时恢复。
信息 io.micrometer.core.instrument.binder.kafka.KafkaMetrics.lambda$checkAndBindMetrics$1[173] -- 无法绑定仪表:kafka.consumer.fetch.manager.[metric2]...但是,这可能发生并且可能下次刷新时恢复。
信息 io.micrometer.core.instrument.binder.kafka.KafkaMetrics.lambda$checkAndBindMetrics$1[173] -- 无法绑定仪表:kafka.consumer.fetch.manager.[metric3]...但是,这可能发生并且可能下次刷新时恢复。
信息 io.micrometer.core.instrument.binder.kafka.KafkaMetrics.lambda$checkAndBindMetrics$1[173] -- 无法绑定仪表:kafka.consumer.fetch.manager.[metric4]...但是,这可能发生并且可能下次刷新时恢复。

它是一个INFO日志级别,带有一些令人放心的结尾词However, this could happen and might be restored in the next refresh.,因此,并不意味着令人担忧,但是在此升级中显示它的目的是什么?

与此同时,我用以下方法抑制了它们(额外的日志): logging.level.io.micrometer.core.instrument.binder.kafka.KafkaMetrics=WARN

spring-boot spring-kafka spring-micrometer

10
推荐指数
1
解决办法
2182
查看次数

Spring Boot - Liquibase - 偶尔需要很长时间(60x)执行

配置

我在类路径上2.3.2.RELEASE使用Spring Boot 。Liquibase

build.gradle 6.4.1:

id 'org.liquibase.gradle' version '2.0.4'
implementation 'org.liquibase:liquibase-core:4.0.0'
Run Code Online (Sandbox Code Playgroud)

application.properties:

spring.liquibase.changeLog=classpath:db/changelog/db.changelog-master.xml
spring.liquibase.user=username
spring.liquibase.password=password
Run Code Online (Sandbox Code Playgroud)

db.changelog-master.xml

<?xml version="1.0" encoding="UTF-8"?>   
<databaseChangeLog  
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">  
   <preConditions>
      <dbms type="oracle"/>
   </preConditions>
   
   <include file="db/changelog/db.changelog-1.0.oracle.sql"/> 
</databaseChangeLog> 
Run Code Online (Sandbox Code Playgroud)

db.changelog-1.0.oracle.sql:

我的sql文件只有8个变更集,这些变更集之前都已经运行过(没有什么新的可以运行),例如:

--liquibase formatted sql

--changeset author:date-1
--preconditions onFail:MARK_RAN
--precondition-sql-check expectedResult:0 SELECT count(*) FROM user_tables WHERE table_name = 'XXX';
SQL 1;
:
Run Code Online (Sandbox Code Playgroud)

DATABASECHANGELOG表有预期的 8 个条目。

问题

我偶尔会遇到延迟问题,特别是当我刚刚启动 STS 4.5.1 IDE(通过 VPN 远程连接到数据库)时,但是当应用程序重新运行/重新启动时,我不会再遇到它,直到将来的某个时间。我无法随意更精确或重现该问题。

因此,我已经设置了logging.level.liquibase=DEBUG,这就是延迟发生地方:

延迟记录(约 4 分钟) …

liquibase spring-boot

5
推荐指数
0
解决办法
1206
查看次数

Kafka - 如何模拟消费者记录?

我需要一些帮助来为我的 Java kafka 消费者构建 Junit 测试用例。

我的原始源代码具有如下方法,并且需要为其创建一个单元测试用例。

@KafkaListener(topics = "${kafka-receiver-topic}")
public void receiveTopic(ConsumerRecord<?, ?> consumerRecord) throws Exception {
    JSONObject kafkaObject = new JSONObject(consumerRecord.value().toString());
}
Run Code Online (Sandbox Code Playgroud)

java mockito apache-kafka junit5

3
推荐指数
1
解决办法
7843
查看次数

JAAS/SASL 的 spring-kafka application.properties 配置不起作用

用例:
我正在使用 Spring Boot2.2.5.RELEASE并且Kafka 2.4.1
JAAS/SASL 配置在 Kafka/ZooKeeper 上正确完成,因为创建的主题没有问题kafka-topics.bat

问题:
当我启动 Spring Boot 应用程序时,我立即收到以下错误:

kafka-server-start.bat 控制台:
INFO [SocketServer brokerId=1] Failed authentication with /127.0.0.1 (Unexpected Kafka request of type METADATA during SASL handshake.) (org.apache.kafka.common.network.Selector)

IDE控制台:
WARN org.apache.kafka.clients.NetworkClient - [Consumer clientId=xxx, groupId=yyy] Bootstrap broker localhost:9093 (id: -3 rack: null) disconnected

我的application.properties配置:

spring.kafka.jaas.enabled=true
spring.kafka.properties.security.protocol=SASL_PLAINTEXT
spring.kafka.properties.sasl.mechanism=PLAIN
spring.kafka.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="spring_bO0t" password="i_am_a_spring_bO0t_user";
Run Code Online (Sandbox Code Playgroud)

kafka_server_jaas.conf

KafkaServer {
    org.apache.kafka.common.security.plain.PlainLoginModule required
    username="admin"
    password="12345"
    user_admin="12345"
    user_spring_bO0t="i_am_a_spring_bO0t_user";
};
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

提前致谢。

spring-kafka

2
推荐指数
2
解决办法
7138
查看次数