[JAVA-33623] Split-or-move-spring-kafka-module (#16419)

This commit is contained in:
vunamtien 2024-04-19 15:07:36 +07:00 committed by GitHub
parent c5f26cf59a
commit 88e3dee91a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 116 additions and 2 deletions

View File

@ -812,6 +812,7 @@
<!--<module>spring-jinq</module>-->
<module>spring-kafka-2</module>
<module>spring-kafka-3</module>
<module>spring-kafka-4</module>
<module>spring-kafka</module>
<module>spring-katharsis</module> <!-- Upgrade to Boot 3 not possible as the project has not been upgraded to Support Jakarta dependencies-->
<module>spring-mobile</module>
@ -1059,6 +1060,7 @@
<!--<module>spring-jinq</module>-->
<module>spring-kafka-2</module>
<module>spring-kafka-3</module>
<module>spring-kafka-4</module>
<module>spring-kafka</module>
<module>spring-katharsis</module> <!-- Upgrade to Boot 3 not possible as the project has not been upgraded to Support Jakarta dependencies-->
<module>spring-mobile</module>

11
spring-kafka-4/README.md Normal file
View File

@ -0,0 +1,11 @@
## Spring Kafka
This module contains articles about Spring with Kafka
### Relevant articles
- [Get the Number of Messages in an Apache Kafka Topic](https://www.baeldung.com/java-kafka-count-topic-messages)
- [Sending Data to a Specific Partition in Kafka](https://www.baeldung.com/kafka-send-data-partition)
- More articles: [[<-- prev]](../spring-kafka-3)

62
spring-kafka-4/pom.xml Normal file
View File

@ -0,0 +1,62 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-kafka-4</artifactId>
<name>spring-kafka-4</name>
<description>Intro to Kafka with Spring</description>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-3</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>${spring-kafka.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.baeldung.spring.kafka.KafkaApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<spring-kafka.version>3.1.2</spring-kafka.version>
<spring-boot.version>3.2.2</spring-boot.version>
<junit-jupiter.version>5.10.2</junit-jupiter.version>
</properties>
</project>

View File

@ -0,0 +1,2 @@
server.port=8081
spring.kafka.bootstrap-servers=localhost:9092

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,7 @@
spring:
kafka:
consumer:
auto-offset-reset: earliest
group-id: baeldung
test:
topic: embedded-test-topic

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
<!-- Reduce the noise as the consumer keeps trying to connect until the Kafka instance is available -->
<springProfile name="ssl">
<logger name="org.apache.kafka.clients.NetworkClient" level="ERROR" additivity="false"/>
</springProfile>
</configuration>

View File

@ -9,8 +9,6 @@ This module contains articles about Spring with Kafka
- [Monitor the Consumer Lag in Apache Kafka](https://www.baeldung.com/java-kafka-consumer-lag)
- [Send Large Messages With Kafka](https://www.baeldung.com/java-kafka-send-large-message)
- [Kafka Streams With Spring Boot](https://www.baeldung.com/spring-boot-kafka-streams)
- [Get the Number of Messages in an Apache Kafka Topic](https://www.baeldung.com/java-kafka-count-topic-messages)
- [Sending Data to a Specific Partition in Kafka](https://www.baeldung.com/kafka-send-data-partition)
- [Implementing Retry in Kafka Consumer](https://www.baeldung.com/spring-retry-kafka-consumer)
### Intro