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
09/26/2023, 6:16 PM
But kafka doesn’t send a pojo!
09/26/2023, 6:17 PM
09/26/2023, 6:27 PM
No problem, you can config a dto o pojo but I prefer always use a json string at the end
09/26/2023, 6:32 PM
the problem is to create the unified senders factory without creating a bean for each topic manually(
09/26/2023, 7:08 PM
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
09/26/2023, 11:50 PM
spring kafka has a kafka template that takes a topic name as a parameter. Not really getting what more you need than that