-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e58e74
commit ef504c3
Showing
5 changed files
with
78 additions
and
69 deletions.
There are no files selected for viewing
49 changes: 0 additions & 49 deletions
49
src/main/java/com/itsnaveenk/spring_kafka_consumer_elastic/Entity/FoodOrderNotification.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/com/itsnaveenk/spring_kafka_consumer_elastic/model/Notification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.itsnaveenk.spring_kafka_consumer_elastic.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | ||
|
||
public class Notification { | ||
|
||
private int user_Id; | ||
|
||
|
||
private String message; | ||
|
||
private int recipient_Id; | ||
|
||
public Notification() { | ||
} | ||
public Notification(int user_Id, String message, int recipient_Id) { | ||
this.user_Id = user_Id; | ||
this.message = message; | ||
this.recipient_Id = recipient_Id; | ||
} | ||
|
||
public int getUser_Id() { | ||
return user_Id; | ||
} | ||
|
||
public void setUser_Id(int user_Id) { | ||
this.user_Id = user_Id; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public int getRecipient_Id() { | ||
return recipient_Id; | ||
} | ||
|
||
public void setRecipient_Id(int recipient_Id) { | ||
this.recipient_Id = recipient_Id; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Notification{" + | ||
"user_Id=" + user_Id + | ||
", message='" + message + '\'' + | ||
", recipient_Id=" + recipient_Id + | ||
'}'; | ||
} | ||
} |
16 changes: 8 additions & 8 deletions
16
src/main/java/com/itsnaveenk/spring_kafka_consumer_elastic/service/KafkaConsumerService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
package com.itsnaveenk.spring_kafka_consumer_elastic.service; | ||
|
||
import com.itsnaveenk.spring_kafka_consumer_elastic.Entity.FoodOrderNotification; | ||
import org.springframework.stereotype.Service; | ||
import com.itsnaveenk.spring_kafka_consumer_elastic.model.Notification; | ||
import org.springframework.kafka.annotation.KafkaListener; | ||
|
||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class KafkaConsumerService { | ||
|
||
@KafkaListener(topics = "foodsOrder", groupId = "springConsumerGroup1") | ||
public void consume(FoodOrderNotification foodOrderNotification) { | ||
System.out.println("Consumed message: " + foodOrderNotification.toString()); | ||
@KafkaListener(topics = "foodsOrder", groupId = "${spring.kafka.consumer.group-id}") | ||
public void listen(Notification notification) { | ||
System.out.println("Received notification: " + notification); | ||
// Process the notification | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
spring.application.name=spring-kafka-consumer-elastic | ||
server.port=8081 | ||
|
||
spring.kafka.bootstrap-servers=localhost:9092 | ||
spring.kafka.bootstrap-servers=localhost:9092 | ||
spring.kafka.consumer.group-id=springConsumerGroup1 |