Kafka with Java: Build a Secure, Scalable Messaging App

Sanmit Deshpande

Hi, my Consumer class in Java is not able to receive the messages. Hence my message list is empty. I have used JSON to post the data and a POJO(KafkaPayload) to store instead of a simple text/string. I’m able to post the data to Kafka topic via REST call.
However running the console_consumer shows the data posted to Kafka.

private final List<kafkapayload> messages = new ArrayList<>();
@KafkaListener(topics = “test_topic”, groupId = “kafka-sandbox”)
public void listener(KafkaPayload data) {
synchronized (messages){
messages.add(data);
}
}