I'm working on an application that uses a Kafka listener using spring-kafka. The problem I'm facing is that the spring context initialization fails when the Kafka listener doesn't turn on (Various reasons, such as Kafka server is not turned on or is down). How can I make sure that my application is independent.
Can anyone please help.
Set autoStartup(false)
on the container factory.
Inject (e.g. @Autowired
) the KafkaListenerEndpointRegistry
and start()
it in your code (in a try/catch).
You can also start/stop containers individually by getting them from the registry (using the @KafkaListener
id
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With