I have a usecase where I want to get the underlying Kafka producer (KafkaTemplate) in a Spring Cloud Stream application. While navigating the code I stumbled upon KafkaProducerMessageHandler
which has a getKafkaTemplate
method. However, it fails to auto-wire.
Also, if I directly auto-wire KafkaTemplate
, the template is initialized with default properties and it ignores the broker
in the binder
key of the SCSt configuration
How can I access the underlying KafkaTemplate or a producer/consumer in a Spring Cloud Stream app?
EDIT: Actually my SCSt app has multiple Kafka binders and I want to get the KafkaTemplate
or Kafka producer corresponding to each binder. Is that possible somehow?