Hello! I wanna write (spring) kafka producers gene...
# spring
e
Hello! I wanna write (spring) kafka producers generator. Our services use a lot of this stuff and I feel it dumb to copy-paste the same beans million times. but I can't invent the flawless solution((( my last idea was to write in config pairs "topic to className". but what to do if one dto should be sent to one of multiple possible topics (multiple topics accept the same dto but some logic defines which one to choose)?.. have somebody seen some idea description (article or post or anything else)?
not kotlin but kotlin colored 1
e
But kafka doesn’t send a pojo!
e
whoops ok dto)
e
No problem, you can config a dto o pojo but I prefer always use a json string at the end
e
the problem is to create the unified senders factory without creating a bean for each topic manually(
s
Not kotlin related, but you should check out Spring Cloud Streams. There are some config driven ways to do message routing and also some easy code driven ways to do it as well.
Our team uses it extensively for the “message routing” use case you’re describing
👍 1
j
spring kafka has a kafka template that takes a topic name as a parameter. Not really getting what more you need than that
❤️ 1