b606e959a76124fe47441dddd0b4469f3f381f9c
[JavaForFun] /
1 package de.example.spring.kafka;
2
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.springframework.kafka.annotation.KafkaListener;
6
7 import java.util.concurrent.CountDownLatch;
8
9 public class Receiver {
10
11   private static final Logger LOGGER = LoggerFactory.getLogger(Receiver.class);
12
13   private CountDownLatch latch = new CountDownLatch(1);
14
15   @KafkaListener(topics = "example.topic")
16   public void receiveMessage(String message) {
17     LOGGER.info("received message='{}'", message);
18     latch.countDown();
19   }
20
21   public CountDownLatch getLatch() {
22     return latch;
23   }
24 }