Hello everyone. I'm trying to create an abstract k...
# announcements
r
Hello everyone. I'm trying to create an abstract kafka consumer with kotlin, with no luck. If anyone can help: https://stackoverflow.com/questions/59950147/make-na-abstraction-to-kafka-consumer-using-ktor-and-kotlin
e
If you’re trying to make
recordingCommand
completely generic-use, I’d recommend having it do one of 2 things: 1. Accept a lambda of the form
(T) -> Unit
where you can pass your deserialized messages inside the for loop as you receive records (easier, but blocking), or 2. Wrap the body of your function inside a kotlin flow and have the for loop invoke
emit()
when it receives new records from Kafka (slightly more complicated, but asynchronous) Either way, you’re going to need to have that function invoke another function to pass the data along to your database.
r
Thanks. But would you have an example of the flow?