File tree Expand file tree Collapse file tree 4 files changed +51
-3
lines changed
java/com/io/example/controller Expand file tree Collapse file tree 4 files changed +51
-3
lines changed Original file line number Diff line number Diff line change 1+ package com .io .example .controller ;
2+
3+ import com .io .example .controller .dto .request .MessageRequestDtoRequest ;
4+ import com .io .example .controller .dto .response .GetDtoResponse ;
5+ import com .io .example .producer .KafkaProducerService ;
6+ import lombok .RequiredArgsConstructor ;
7+ import org .springframework .http .HttpStatus ;
8+ import org .springframework .http .ResponseEntity ;
9+ import org .springframework .web .bind .annotation .*;
10+
11+ @ RestController
12+ @ RequiredArgsConstructor
13+ @ RequestMapping ("/v1/example" )
14+ public class ExampleController {
15+
16+ private final KafkaProducerService kafkaProducerService ;
17+
18+ @ PostMapping ("/send" )
19+ public ResponseEntity <GetDtoResponse > sendMessage (@ RequestBody MessageRequestDtoRequest dto ){
20+ this .kafkaProducerService .sendMessage (dto .message ());
21+ return ResponseEntity .status (HttpStatus .OK ).body (new GetDtoResponse ("Message sent successfully!" ));
22+ }
23+
24+ }
Original file line number Diff line number Diff line change 33 application :
44 name : spring-kafka-example-dev
55
6+ kafka :
7+ topics :
8+ topic-1 : ${KAFKA_TOPIC_1:spring-kafka-example-topic}
9+ bootstrap-servers : localhost:9092
10+ consumer :
11+ group-id : spring-kafka-example-group
12+ auto-offset-reset : earliest
13+ key-deserializer : org.apache.kafka.common.serialization.StringDeserializer
14+ value-deserializer : org.apache.kafka.common.serialization.StringDeserializer
15+ listener :
16+ missing-topics-fatal : false
17+
618logging :
719
820 pattern :
9- console : " %d{yyyy-MM-dd'T'HH:mm:ss} | ${spring.application.name} | %class{30} | %level | %m%n"
21+ console : " %d{yyyy-MM-dd'T'HH:mm:ss} | ${spring.application.name} | %class{30} | %level | %m%n"
22+
23+ level :
24+ org.apache.kafka.common.config : OFF
Original file line number Diff line number Diff line change 33 application :
44 name : spring-kafka-example-prd
55
6+ kafka :
7+ bootstrap-servers : ${KAFKA_SERVER_PORT}
8+ consumer :
9+ group-id : myGroup
10+ auto-offset-reset : earliest
11+
612logging :
713
814 pattern :
9- console : " %d{yyyy-MM-dd'T'HH:mm:ss} | ${spring.application.name} | %class{30} | %level | %m%n"
15+ console : " %d{yyyy-MM-dd'T'HH:mm:ss} | ${spring.application.name} | %class{30} | %level | %m%n"
16+
17+ level :
18+ org.apache.kafka.common.config : OFF
Original file line number Diff line number Diff line change 44import org .springframework .boot .test .context .SpringBootTest ;
55
66@ SpringBootTest
7- class SpringKafkaExampleApplicationTests {
7+ class SpringKafkaExampleExampleConsumerTests {
88
99 @ Test
1010 void contextLoads () {
You can’t perform that action at this time.
0 commit comments