spring-kafka-test 相关问题


如何在 Kubernetes multipod 部署中使用 spring kafka 处理 Kafka 容器生命周期

我正在使用 Spring kafka 实现,我需要通过 REST API 启动和停止我的 kafka 消费者。为此,我正在使用 KafkaListenerEndpointRegistry endpointRegistry 端点注册表。


Spring Boot 3.1.X及以上版本的Kafka客户端连接问题

我最近将我的一项 Spring Boot 服务升级到 3.1.x,升级后我遇到了 kafka 问题。它似乎无法连接并不断向我提供以下日志。 2024-01-03T06:18...


如何在spring-boot web客户端发送请求体?

我在 Spring Boot Web 客户端发送请求正文时遇到一些问题。尝试发送如下所示的正文: val 主体 = "{ ” + "\"电子邮件\":\"[email protected]\", ” + “\”id\“:...


Camel Kafka接收器连接器配置和依赖项

我正在尝试使用“camel-azure-storage-datalake-kafka-connector”从 Kafka 连接到 Azure ADLS Gen2 我有一个运行 Docker 的 Linux 机器,其中包含 debezium/zookeeper、debezium/kafka 和 debe...


Kafka Java Consumer Client 是单线程的吗

我们正在开始使用 Kafka, 在阅读本文时 - https://docs.confluence.io/kafka-clients/java/current/overview.html - 它似乎暗示客户端是单线程的。 * 由于这个...


使用kafka密钥的kafka s3连接器分区

如何使用 kafka msg key 作为 s3 连接器中的分区标准或 我怎样才能获得密钥并将其存储在 s3 对象中 谢谢!


Kafka Connect S3 Sink 添加元数据

我正在尝试将元数据添加到 kafka 的输出到 S3 存储桶中。 目前,输出只是来自 kafka 主题的消息的值。 我想用下面的东西把它包起来......


Spring boot + slf4j + log4j + 类 org.apache.logging.slf4j.SLF4JLoggerContext 无法转换为类

我有Spring boot 2.3.1 pom.xml 我有Spring boot 2.3.1 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.3.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>logger</groupId> <artifactId>logger</artifactId> <version>0.0.1-SNAPSHOT</version> <name>logger</name> <description>Demo project for Spring Boot</description> <properties> <java.version>11</java.version> <lombok.version>1.18.12</lombok.version> <log4j.version>1.2.17</log4j.version> <slf4j.version>1.7.30</slf4j.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <artifactId>logback-classic</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> 班级 @Slf4j @SpringBootApplication public class LoggerApplication { public static void main(String[] args) { log.info("++++++++++++++++++++++++TEST+++++++++++++++++++++++++++++"); SpringApplication.run(LoggerApplication.class, args); } } 应用程序.属性 logging.config=classpath:log4j.properties log4j.properties log4j.rootLogger=INFO, console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.Target=System.out log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p - %m%n 我尝试寻找解决方案,查看论坛上的类似主题,尝试各种排除依赖项的选项。 线程“main”中的异常 java.lang.ClassCastException:类 org.apache.logging.slf4j.SLF4JLoggerContext 无法转换为类 org.apache.logging.log4j.core.LoggerContext (org.apache.logging.slf4j.SLF4JLoggerContext 和 org.apache.logging.log4j.core.LoggerContext 位于未命名模块中 加载器“应用程序”)位于 我还尝试排除一些依赖项 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <artifactId>logback-classic</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>*</artifactId> </exclusion> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>*</artifactId> </exclusion> </exclusions> </dependency> 但又出现错误,但现在无法再格式化日志了。 2021-01-13 19:12:15,881 信息 - ++++++++++++++++++++++++测试+++++++++++++++++++++++++++++++ 错误 StatusLogger 无法识别的格式说明符 [d] 错误 StatusLogger 无法识别的转换说明符 [d] 从转换模式中的位置 16 开始。 错误 StatusLogger 无法识别的格式说明符 [线程] 错误 StatusLogger 无法识别的转换说明符 [线程] 从转换模式中的位置 25 开始。 错误 StatusLogger 无法识别的格式说明符 [级别] 错误 StatusLogger 无法识别的转换说明符 [level] 从转换模式中的位置 35 开始。 ... 错误 StatusLogger 无法识别的格式说明符 [n] 错误 StatusLogger 无法识别的转换说明符 [n] 从转换模式中的位置 56 开始。 警告:不支持 sun.reflect.Reflection.getCallerClass。这会影响性能。 任何人都可以有任何想法如何解决它吗? 我找到了解决这个问题的方法。事实证明,问题出在其中一个私有库(elastik 的附加程序)的冲突上。 我执行了命令: mvn dependency:tree 然后找到传递依赖项,并将它们排除在所有类的路径上,以排除日志记录所需的库冲突。 pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <artifactId>logback-classic</artifactId> <groupId>ch.qos.logback</groupId> </exclusion> <exclusion> <artifactId>log4j-to-slf4j</artifactId> <groupId>org.apache.logging.log4j</groupId> </exclusion> </exclusions> </dependency> <dependency> <artifactId>springfox-boot-starter</artifactId> <groupId>io.springfox</groupId> <version>3.0.0</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>${log4j.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>${version.log4j.core}</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${slf4j.version}</version> </dependency>


即使部署在 kubernetes pod 上,kafka 主题仍然是不可变的吗?

我在 kubernetes pod 上部署了 kafka 主题和模式注册表,我尝试修改/更改 kafka 主题和模式注册表的清单文件,然后模式注册表的行为在


使用 kafka-go 和循环平衡器时,数据始终进入分区 0

我正在使用 kafka-go 库将消息写入 Kafka。我正在使用循环平衡器,但数据始终进入分区 0。我尝试忽略所有消息的分区字段,但是...


如何使用 .NET TEST EXPLORER 在 VS Code 中运行 NUnit 测试

我想从 .NET TEST EXPLORER 运行单元测试,而不是命令行。我可以在导航到单元测试目录并执行 dotnet test 时运行测试。 但选择 .NET TEST EXPLORER...


从 Kafka Consumer 传递数据

我想从Kafka获取数据,此方法成功获取记录但无法传递给变量。这是我的代码 公共无效 subscribeFromKafka() 抛出异常 { 列表结果=新


依赖更新后构建kafka生产者失败

在我的 SpringBoot Java 项目中,我使用的是 kafka,特别是 ReactiveKafka。我正在更新依赖项,特别是这些依赖项: springboot 2.6.6 -> 3.1.5 弹簧卡夫卡 2.8.0 -> 3.0.11 反应堆-


闪亮的server.R无法读取全局变量

./app 中的两个文件 ui.R 图书馆(闪亮) 一个<- 1 ui <- fluidPage( textOutput("test") ) server.R server <- function(input, output) { output$test <- renderText({ a ...


php 使用函数更改函数外部变量的值

我试图在使用函数时更改函数外部声明的变量的值 我试图更改在使用函数时声明的变量的值 <?php $test = 1; function addtest() { $test = $test + 1; } addtest(); echo $test; ?> 但似乎不能。只有在函数中声明为参数的变量才有效。有这方面的技术吗?预先感谢 将函数内部的变量更改为全局变量 - function addtest() { global $test; $test = $test + 1; } 使用全局变量有很多注意事项 - 从长远来看,您的代码将更难维护,因为全局变量可能会对未来的计算产生不良影响,您可能不知道如何操纵变量。 如果重构代码并且函数消失,这将是有害的,因为 $test 的每个实例都与代码紧密耦合。 这里有一个轻微的改进,不需要 global - $test = 1; function addtest($variable) { $newValue = $variable + 1; return $newValue; } echo $test; // 1 $foo = addtest($test); echo $foo; // 2 现在您不必使用全局变量,并且可以根据自己的喜好操作 $test,同时将新值分配给另一个变量。 不确定这是否是一个人为的示例,但在这种情况下(与大多数情况一样),使用global将是极其糟糕的形式。为什么不直接返回结果并分配返回值呢? $test = 1; function increment($val) { return $val + 1; } $test = increment($test); echo $test; 这样,如果您需要增加除 $test 之外的 任何其他 变量,您就已经完成了。 如果您需要更改多个值并返回它们,您可以返回一个数组并使用 PHP 的 list 轻松提取内容: function incrementMany($val1, $val2) { return array( $val1 + 1, $val2 + 1); } $test1 = 1; $test2 = 2; list($test1, $test2) = incrementMany($test1, $test2); echo $test1 . ', ' . $test2; 您还可以使用 func_get_args 接受动态数量的参数并返回动态数量的结果。 使用 global 关键字。 <?php $test = 1; function addtest() { global $test; $test = $test + 1; } addtest(); echo $test; // 2 ?> 也许你可以试试这个。 <?php function addTest(&$val){ # Add this & and val will update var who call in from outside $val += 1 ; } $test = 1; addTest($test); echo $test; // 2 $anyVar = 5; addTest($anyVar); echo $anyVar; // 6


Kafka UI 无法连接到 Broker

我是容器化新手。我正在尝试设置我的本地环境,我的 java 应用程序想要连接到 Kafka。无法使用 Docker,所以决定使用 Podman。我有三个容器在同一个上运行


有没有办法将AWS Cloudwatch日志输入Kafka主题

我正在努力寻找这方面的任何方向。我有一个内部系统可以处理日志以进行监控。我希望从 Cloudwatch 发送错误并在 kafka 主题上发布,其中...


Kafka:如何使用 Java API 从主题中删除记录?

我正在寻找一种从 Kafka 主题中删除(完全删除)已使用记录的方法。我知道有几种方法可以做到这一点,通过更改主题的保留时间或删除...


Kafka 总是有一个消费者消费一组中的主题消息

我有两个具有相同组ID的消费者服务器订阅了相同的主题。 一台 kafka 服务器仅运行一个分区。 据我所知,消息应该在这两个中随机消耗


具有手动偏移提交功能的 Kafka 消费者客户端一次只允许客户端

我目前正在使用一个Java Kafka消费者,它手动提交偏移量(enable.auto.commit = false),我发现即使我生成了多个实例,我发现这样的设置也是如此


如何仅删除已消费的消息以及如何在kafka主题中显示未消费的消息?

我们将一个项目从ActiveMQ迁移到Kafka。 过去我们向很多队列写入了太多的消息,消费完之后,ActiveMQ会自动删除消费的消息。仅未消耗


在结构化流 API 中跨多个集群使用共享 Kafka 主题执行 Spark 作业

我正在开发一个 Spark 项目,我需要在两个不同的集群上运行作业,两个集群都使用相同的 Kafka 主题。我希望这些作业能够有效地共享负载并平衡


将 Spring Security 5 迁移到 Spring Security 6 HttpSecurity 问题

Spring Security 6 中以下代码应该替代什么? http .authorizeRequests() .requestMatchers("/hub/**").access("hasPermission('SOME_LAYER', '')")...


Spring Boot 版本与 Java 11 兼容

大家好,目前我正计划将具有 spring 版本 4.0.6 和 java 8 的独立 spring 应用程序迁移到具有 java 11 的 Spring boot 应用程序。所以,继续使用 spring boot


指定psql连接的默认数据库?

在使用psql时,我想更改初始数据库连接。 我有一个名为“test”的数据库作为初始连接。 从命令行运行 psql 时,我的提示符为 test=# 之后


grpc-spring-boot-starter - 如果我将 spring-boot-starter-jdbc 添加到依赖项中,netty 服务器不会启动

我开始用spring boot测试grpc,我使用net.devh中提供的GrpcService:grpc-spring-boot-starter(https://yidongnan.github.io/grpc-spring-boot-起动器/en/)。 它隔离效果很好...


写入通道的随机结果(Go)

我有以下代码: 函数 writeToClosedBufferedChannel() { ch := make(chan int, 2) ch <- 10 ch <- 20 go func() { fmt.Println("test") ch <- ...


如何在Spring Boot 3和Spring Framework 6中注册拦截器

我正在使用 Spring Boot 3.1.0-SNAPSHOT 构建后端,它使用 Spring Framework 6x。 拦截器: @Slf4j 公共类 MyInterceptor 实现 HandlerInterceptor { @覆盖 公众嘘声...


使用Pytest时将主数据库更改为Test

帮我解决问题 这是我的设置.py: 数据库= { “默认”: { "ENGINE": "django.db.backends.mysql", “名称”:ENV.MYSQL_DSN....


Jaxb2Marshaller 与 Spring boot 3+ 和 Jaxb 4 兼容吗?

我正在将我的项目从 Spring Boot 2.7 升级到 Spring Boot 3.1。在这个项目中仍然使用 SOAP,因此我们依赖 Jaxb 和 spring WS。 我正在使用 com.helger.maven 生成 Java 类:


Python KafkaTimeoutError:等待未来超时

我正在使用 Kafka 将日志发送到主题。发送消息时,我总是收到此错误 消息:“测试日志” 参数:() --- 记录错误 --- 回溯(最近一次调用最后一次): 文件“...


Spring @Transactional 迁移到 Spring 5 后不起作用

我最近将应用程序从带有 AspectJ 1.8.10 的 Spring 4.3.x 和 JDK 8 升级到带有 Spring 5.3.x 和 AspectJ 1.9.20.1 的 JDK 17,并且事务注释似乎不起作用 在应用中...


Apache Spark Structured Streaming 中 Spark UI 上的查询和阶段卡住了

我在 EMR 集群 (6.14) 上使用 Apache Spark Structured Streaming (3.1.2)。 Spark 结构化流将数据从 Apache Kafka 流式传输到 Delta Lake 表。当我打开 Spark UI 时,我看到以下内容


debezium 日期/时间字段值超出范围:0000-12-30T00:00:00Z

我们使用 Debezium 将数据同步到 在源表中我们有列timestamptz start_at,当值为0时start_at='0001-01-01 00:00:00.000000 +00:00',但是当我们检查kafka中的数据时,它是


bean“mvcHandlerMappingIntrospectorRequestTransformer”无法注册。具有该名称的 bean 已被定义并覆盖 i

环境:Spring Boot 3.2.1、JDK 21、GraalVM、Spring Native、Spring Security。错误 微软Windows [版本10.0.22631.2861] (c) 微软公司。版权所有。 。 ____ ...


Spring Boot api 在多次成功的 200 响应后给出 403

我有一个 Spring Boot 应用程序,它使用 spring security 作为依赖项。我正在将 Spring boot 版本从 2.7.16 迁移到 3.2.1。在 2.7.16 版本中一切正常。但在 3.2.1 中,其余 API 都...


如何在Spring 3.0中实现Scaffolding

“我正在使用 spring maven 项目,想要在其中实现脚手架,以便我可以根据模型动态生成 DAO、服务和 spring 表单。如何实现?”


来自有序字典的Python Json

我正在尝试创建一个嵌套的 Json 结构,如下所示: 示例 Json: { “id”:“德”, “密钥”:“1234567”, “来自”:“[email protected]”, “过期”:“2018-04-2...


Groovy 抛出 可能的解决方案:解析 LinkedHashMap 时出现 parseText(java.lang.String) 错误

我正在尝试检查kafka输出消息中是否存在该密钥,如果存在则进行进一步的操作。 卡夫卡主题的输出消息如下 [“随机名称_547hcg”:{ “访问_...


如何删除AWS MSK集群中的kafka状态存储

我有一个使用 AWS 上的 MSK 集群的 kafkaStreams 应用程序。 我需要清理状态存储(在我的应用程序中使用一些 KTable 后创建)。 我找不到任何方法来访问文件系统......


如何使用xslt将xml中的文本转换为html中的超链接

如何使用 xslt 将 xml 中的文本转换为 html 中的超链接。 我的 Xml 代码是 C:\测试\CaptureF15165617TC001_05_06_1516_57_11.png 如何使用 xslt 将 xml 中的文本转换为 html 中的超链接。 我的Xml代码是 <Steps> <Filepath>C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</Filepath> </Steps> 将其转换为 html,我的 xslt 代码如下 <td width='15%'> <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> <xsl:value-of select="./Filepath"/> </xsl:element> </td> 现在这段代码在html中写入文件的整个路径,但我只想在html中写入“文件”以及指向文件位置的超链接。 我当前生成的html代码如下 C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png <td width="15%"><a href="C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png">C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</a></td> 我想要的是 <td width="15%"><a href="C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png">File</a></td> 任何人都可以帮助我需要在 xslt 中进行哪些更改。 你告诉它具有价值: <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> <xsl:value-of select="./Filepath"/> <!--This is the link text --> </xsl:element> 所以将其更改为: <xsl:element name="a"> <xsl:attribute name="href"> <xsl:value-of select="./Filepath"/> </xsl:attribute> File </xsl:element> 或者简短地说: <a href="{Filepath}">File</a> <Steps> <Filepath>C:\Test\Capture\050615165617TC001_05_06_1516_57_11.png</Filepath> </Steps>


自消息发布或 sinse 服务器启动以来,kafka 是否计数 log.retatantion

如果我将 log.retantion 设置为 24 小时,则在 1.1.24 15:30 发布了一条消息。 然后服务器宕机了25小时,24年1月16日16:30再次启动,消息会立即删除吗...


Spring Boot 集成测试抛出错误“java.lang.IllegalStateException:阻塞读取超时 5000 毫秒”

问题发生在我通过 Spring boot 2.0.0.M3 使用 Spring webflux 的项目上。以下是项目的依赖项, 依赖项{ 编译 'org.springframework.boot:spring-boot-starter-


mod_rewrite到子目录中相应的php文件

我想使用 mod_rewrite (在 .htaccess 中)将“干净”的 URL 映射到子目录中相应的 php 文件,例如: https://example.com/test/ --> https://example.com/p/test.php 我的...


AWS sts 在一个命令中承担角色

要在 CLI 中承担 AWS 角色,我执行以下命令: aws sts 假设角色 --role-arn arn:aws:iam::123456789123:role/myAwesomeRole --role-session-name test --region eu-central-1 这给...


ASP Fix/Int 函数未按预期运行

在调试时,我在自定义 RoundMid() 函数中发现了这个奇怪的事情: 测试 = 148.325 * 100 + 0.5 Response.Write 测试 ' 返回 14833 Response.Write Fix(test) ' 返回 14832 ??????...


React 应用程序如何连接到 OAuth 2 Spring 授权服务器/资源服务器/oauth 客户端后端

我已经实现了一个生成令牌的 OAuth 2 spring 授权服务器。端口4002 用于 api 调用的 spring 资源服务器。端口4003 一个 spring oauth 客户端,用于处理与


Spring Boot JSP 404.Whitelabel 错误页面

无法使用 spring-boot 加载非常简单的 JSP 页面,出现 404 Not Found HmisApplication.class @SpringBootApplication 公共类 HmisApplication 扩展 SpringBootServletInitializer { @覆盖


如何从.Net Core中的Content.ReadAsStringAsync方法获取字符串?

我正在尝试读取 WEB API 的响应,该响应返回字符串。 我使用下面的语句: response.Conent.ReadAsStringAsync().Result.ToString(); 我期待结果是“TEST”...


通过 Maven Spring Boot 插件运行应用程序时如何设置 Java Xmx 标志?

我正在使用 mvn spring-boot:run 运行应用程序。我正在尝试按照此处所述设置 Xmx 标志: mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xmx512m" 但它不...


© www.soinside.com 2019 - 2024. All rights reserved.