java-tutorials/spring-kafka
Harry9656 6b0c4b9a80
JAVA-26760: Updated and standardized the junit-jupiter-engine library (#16357)
* JAVA-26760: Updated and standardized the junit-jupiter-engine library

* JAVA-26760: Updated and standardized the mockito-junit-jupiter library

* fix mockito-junit-jupiter properties

* fix maven-custom-plugin/usage-example properties

* Fix quarkus-funqy

* JAVA-26760: Fix NamespacedHierarchicalStore error in junit
2024-04-23 18:45:06 +02:00
..
src [JAVA-33623] Split-or-move-spring-kafka-module (#16419) 2024-04-19 11:07:36 +03:00
README.md [JAVA-33623] Split-or-move-spring-kafka-module (#16419) 2024-04-19 11:07:36 +03:00
pom.xml JAVA-26760: Updated and standardized the junit-jupiter-engine library (#16357) 2024-04-23 18:45:06 +02:00

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!!