Skip to content

Commit 68f00d7

Browse files
committed
Update
1 parent 530ced9 commit 68f00d7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/main/java/com/example/integrationtestspringkafka/service/ConsumerService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ public class ConsumerService {
1717
this.exampleRepository = exampleRepository;
1818
}
1919

20+
/**
21+
* Consume ExampleDTO on topic : TOPIC_EXAMPLE
22+
* Then save it in database.
23+
*
24+
* @param exampleDTO
25+
*/
2026
@KafkaListener(topics = "TOPIC_EXAMPLE")
2127
public void consumeExampleDTO(ExampleDTO exampleDTO) {
2228
log.info("Received from topic=TOPIC_EXAMPLE ExampleDTO={}", exampleDTO);

src/main/java/com/example/integrationtestspringkafka/service/ProducerService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@
1010
public class ProducerService {
1111
Logger log = LoggerFactory.getLogger(ProducerService.class);
1212

13-
private String topic = "TOPIC_EXAMPLE";
13+
private String topic = "TOPIC_EXAMPLE_EXTERNE";
1414

1515
private KafkaTemplate<String, ExampleDTO> kafkaTemplate;
1616

1717
ProducerService(KafkaTemplate kafkaTemplate) {
1818
this.kafkaTemplate = kafkaTemplate;
1919
}
2020

21+
/**
22+
* Send ExampleDTO to an external topic : TOPIC_EXAMPLE_EXTERNE.
23+
*
24+
* @param exampleDTO
25+
*/
2126
public void send(ExampleDTO exampleDTO) {
2227
log.info("send to topic={} ExampleDTO={}", topic, exampleDTO);
2328
kafkaTemplate.send(topic, exampleDTO);

0 commit comments

Comments
 (0)