Reputation: 751
I have seen from the KafkaTemplate implementation that there is no access to the actual Kafka Producer. While this Producer wrapping might be good, there are some methods from the Kafka Producer that are needed like metrics()
and partitionsFor(java.lang.String topic)
.
In KafkaTemplate we could have these same methods wrapping the actual Kafka Producer methods.
Is this something likely to be implemented in newer versions?
Could I implement it and make a pull request?
Upvotes: 2
Views: 1779
Reputation: 174739
In accordance with Kafka guidelines, the DefaultKafkaProducerFactory
always returns the same producer, so it's safe to call createProducer
to get a reference to the single producer.
Calling close()
on the producer is ignored.
However, I have opened a GitHub Issue to provide access to the producer from the template.
Upvotes: 3