spring-attic / spring-integration-kafka

Apache License 2.0
325 stars 179 forks source link

GH-290: Add ProducerRecordCreator #291

Closed garyrussell closed 4 years ago

garyrussell commented 4 years ago

Resolves https://github.com/spring-projects/spring-integration-kafka/issues/290

garyrussell commented 4 years ago

See https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/790

We would have to make changes in the binder and it still won't help with his customization of the output record. With this solution, the user is free to use your recently merged message handler customizer.

artembilan commented 4 years ago

And why is that?

He creates a ProducerRecord in his code whatever way he needs it with all the possible record customization. Returns that record from the microservice function and our KafkaProducerMessageHandler just propagates it as is into underlying KafkaTemplate.

We don't need any customizers. More over a solution with this creator still may have flaws not letting to get access to something what could be better done in the upstream transformer. In other words: it is not a KafkaProducerMessageHandler responsibility to transform a payload "hard" way.

Again: I'm not against your solution which is simply lambda from end-user perspective. I just want to share thoughts about what we have so far in other places. Otherwise there is really no limits with Function-based fine-graining...

garyrussell commented 4 years ago

Again; think about it in the context of the kafka binder, not an SI application.

What if all he wants to do is add a custom header - and use all the goodness of the binder to create all the other properties of the record?