File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
src/main/java/com/example/integrationtestspringkafka/service Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff 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 );
Original file line number Diff line number Diff line change 1010public 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 );
You can’t perform that action at this time.
0 commit comments