Reputation: 481
We have a spring boot application, that uses spring-kafka. We want to disable kafka producer (kafkatemplate), when we update a config property. I have tried with conditional bean, and using applicationcontext refresh.
Is there a way to gracefully shutdown kafkaproducer with spring-kafka ?
Upvotes: 2
Views: 4949
Reputation: 174554
You can call destroy()
on the DefaultKafkaProducerFactory
and it will close the (singleton) producer, but the next time some code calls createProducer()
another one will be created; there's currently no way to prevent that. You would need to subclass the factory and throw an exception when you don't want a producer to be created.
Upvotes: 1