7681ab51e3a605386602f31adbf6928100b2cc34
[JavaForFun] /
1 package de.example.spring.kafka;
2
3 import javax.inject.Inject;
4
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
7 import org.springframework.cloud.stream.annotation.EnableBinding;
8 import org.springframework.cloud.stream.annotation.StreamListener;
9 import org.springframework.cloud.stream.messaging.Sink;
10
11 @EnableBinding(Sink.class)
12 public class Receiver {
13   private static final Logger LOGGER = LoggerFactory.getLogger(Receiver.class);
14   
15   private final DummyService dummyService;
16
17   @Inject
18   public Receiver(DummyService dummyService) {
19         this.dummyService = dummyService;
20   }
21
22   @StreamListener(Sink.INPUT)
23   public void handle(Product product) {
24     LOGGER.info("product name='{}'", product.getName());
25     LOGGER.info("product description='{}'", product.getDescription());
26     
27     dummyService.iAmVeryDummy(product.getName());
28   }
29
30 }