eb1f4e1e90
* JAVA-5875: Upgrade Spring Boot to 2.5.1 * JAVA-5875: Leave jta module on Spring Boot 2.4.7 * JAVA-5875: Update spring-boot-persistence-mongodb to use embedded Mongo 3.0 * JAVA-5875: Leave spring-data-dynamodb on Spring Boot 2.4.7 * JAVA-5875: ErrorController#getErrorPath has been removed * JAVA-5875: Fix SQL Script DataSource Initialization * JAVA-5875: ErrorController#getErrorPath has been removed * JAVA-5875: Fix RepositoryRestConfigurer * JAVA-5875: Fix issues caused by rest-assured upgrade * JAVA-5875: Upgrade spring-cloud-dependencies to 2020.0.3 * JAVA-5875: Leave spring-boot-keycloak on Spring Boot 2.4.7 * JAVA-5875: Fix data.sql script initialization * JAVA-5875: Leave spring-security-legacy-oidc on Spring Boot 2.4.7 * JAVA-5875: Fix data.sql script initialization * JAVA-5875: Fix data.sql script initialization * JAVA-5875: Update de.flapdoodle.embed.mongo dependency * JAVA-5875: Upgrade spring-cloud-dependencies to 2020.0.3 * JAVA-5875: Update Spring Cloud dependencies * JAVA-5875: Update cloud dependencies * JAVA-5875: Defer datasource initialization * JAVA-5875: Fix rest assured version * JAVA-5875: Fix Spring Batch serialization issue * JAVA-5875: Update Spring Cloud Stream version * JAVA-5875: Update Spring Kafka version * JAVA-5875: Leave spring-zuul-rate-limiting on Spring Boot 2.4.7 Co-authored-by: Krzysztof Woyke <krzysztof.woyke.sp@lhsystems.com> |
||
---|---|---|
.. | ||
src | ||
README.md | ||
pom.xml |
README.md
Spring Kafka
This module contains articles about Spring with Kafka
Relevant articles
Intro
This is a simple Spring Boot app to demonstrate sending and receiving of messages in Kafka using spring-kafka.
As Kafka topics are not created automatically by default, this application requires that you create the following topics manually.
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic baeldung
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 5 --topic partitioned
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic filtered
$ bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic greeting
When the application runs successfully, following output is logged on to console (along with spring logs):
Message received from the 'baeldung' topic by the basic listeners with groups foo and bar
Received Message in group 'foo': Hello, World!
Received Message in group 'bar': Hello, World!
Message received from the 'baeldung' topic, with the partition info
Received Message: Hello, World! from partition: 0
Message received from the 'partitioned' topic, only from specific partitions
Received Message: Hello To Partioned Topic! from partition: 0
Received Message: Hello To Partioned Topic! from partition: 3
Message received from the 'filtered' topic after filtering
Received Message in filtered listener: Hello Baeldung!
Message (Serialized Java Object) received from the 'greeting' topic
Received greeting message: Greetings, World!!