https://kotlinlang.org logo
#announcements
Title
# announcements
r

Rodrigo Silva

01/28/2020, 1:45 PM
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

Evan R.

01/28/2020, 1:55 PM
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

Rodrigo Silva

01/28/2020, 1:58 PM
Thanks. But would you have an example of the flow?
5 Views