Skip to content

Commit 718f82a

Browse files
committed
kafka producer for location coordinates
1 parent dc28fea commit 718f82a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/main/java/com/deliveryapp/controller/LocationController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ public LocationController(KafkaService kafkaService) {
2727
public ResponseEntity<?> updateLocation(){
2828

2929
// using random numbers representing the live coordinates -- latitude and longitude
30-
kafkaService.updateLocation("(" + Math.round(Math.random()*100) + ", " + Math.round(Math.random()*100) + ")");
30+
for(int i =0; i < 100000; i++) {
31+
kafkaService.updateLocation("(" + Math.round(Math.random()*100) + ", " + Math.round(Math.random()*100) + ")");
32+
}
3133
return new ResponseEntity<>(Map.of("message", "location updated"), HttpStatus.OK);
34+
35+
// kafkaService.updateLocation("(" + Math.round(Math.random()*100) + ", " + Math.round(Math.random()*100) + ")");
36+
// return new ResponseEntity<>(Map.of("message", "location updated"), HttpStatus.OK);
3237
}
3338
}
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11

2-
#Apache Kafka configuration
3-
4-
# As our KafkaTemplate expects two parameters as String inputs
5-
# Hence, need both serializer for both the Strings
6-
7-
# Producer configuration
2+
# Apache Kafka Producer configuration
83
spring.kafka.producer.bootstrap-servers = localhost:9092
94
spring.kafka.producer.key-serializer = org.apache.kafka.common.serialization.StringSerializer
105
spring.kafka.producer.value-serializer = org.apache.kafka.common.serialization.StringSerializer

0 commit comments

Comments
 (0)