Skip to content

Commit

Permalink
Merge pull request #5 from HRV-Mart/Added_kafka_supoprt_for_deleting_…
Browse files Browse the repository at this point in the history
…user

Added kafka supoprt for deleting user
  • Loading branch information
Harsh3305 authored Mar 28, 2023
2 parents 7c9468f + 58b32fc commit f5a52f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "com.hrv.mart"
version = "0.0.2"
version = "0.0.1"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
Expand Down
10 changes: 8 additions & 2 deletions src/main/kotlin/com/hrv/mart/userlibrary/UserProducer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ class UserProducer (
private val kafkaTemplate: KafkaTemplate<String, User>
) {
fun createUser(user: User) {
sendMessage(user, UserTopics.createUserTopic)
}
fun deleteUser(userId: String) {
sendMessage(userId, UserTopics.deleteUserTopic)
}
private fun <T : Any> sendMessage(data: T, topic: String) {
val message = MessageBuilder
.withPayload(user)
.setHeader(KafkaHeaders.TOPIC, UserTopics.createUserTopic)
.withPayload(data)
.setHeader(KafkaHeaders.TOPIC, topic)
.build()
kafkaTemplate.send(message)
}
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/hrv/mart/userlibrary/UserTopics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package com.hrv.mart.userlibrary
class UserTopics {
companion object {
const val createUserTopic = "CREATE_USER_TOPIC"
const val deleteUserTopic = "DELETE_USER_TOPIC"
}
}

0 comments on commit f5a52f6

Please sign in to comment.