1. Did you verify your kafka setup by producing from producer console and
then seeing the output for that topic on consumer console? If not, please
do that to validate your kafka setup itself.

2. You don't need a kafka consumer class in Springboot Java code - unless u
plan to do some processing in your code after consuming the data. For
testing at this point, I think the kafka consumer console should be enough.

3. On what basis are u saying that kafka produce worked? Usually, when u do
kafkaProducer.send() in Java code, an exception will be thrown if there is
a failure. Did you check for that? If you are ok, pl share code snippet
here.

On Sun, Aug 17, 2025 at 9:18 PM KIRAN KUMAR B O <bokiranku...@gmail.com>
wrote:

> Hi,
>
> I am learning Apache Kafka and Spring Boot. I have a Kafka 4.0 broker
> running locally and a Spring Boot application sending messages to a topic
> javaguides.
>
> *Below steps I followed:*
>
>    1.
>
>    Started Kafka broker on localhost:9092.
>    2.
>
>    Verified the topic exists:
>
> .\bin\windows\kafka-topics.bat --bootstrap-server localhost:9092 --list
>
> Output: javaguides
>
>
> 3. Sent a message via Spring Boot:
>
> http://localhost:8080/api/v1/kafka/publish?message=Hello Kafka
>
> Spring Boot logs confirm the message is sent successfully.
> 4. Tried to consume messages using console consumer:
>
> .\bin\windows\kafka-console-consumer.bat --bootstrap-server
> localhost:9092 --topic javaguides --from-beginning
>
> The console consumer starts but *does not display any messages*, even
> though the topic has data.
>
> *Kafka Version:* 4.0
> *Spring Boot Version:* 3.x
> *Spring Kafka Configuration:*
>
>
> spring.kafka.consumer.bootstrap-servers=localhost:9092spring.kafka.consumer.group-id=mygroupspring.kafka.consumer.auto-offset-reset=earliestspring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializerspring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
>
> spring.kafka.producer.bootstrap-servers=localhost:9092spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializerspring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
>
> *Notes:*
>
>    -
>
>    I have *not created a consumer class* in Spring Boot; I am relying on
>    the console consumer to read messages.
>
> *Questions:*
>
>    1.
>
>    Why does the console consumer not show messages sent by my Spring Boot
>    producer?
>    2.
>
>    Is a Spring Boot KafkaConsumer class required for messages to appear in
>    the console consumer?
>    3.
>
>    Are there any Kafka 4.0 configuration changes that could prevent the
>    console consumer from receiving messages?
>
> Any guidance would be greatly appreciated!
>
> Thank you,
> Kiran Kumar B O
>

Reply via email to