0

I'm running some tests for my spring boot app where if the Kafka/zookeepers are not available (as in not resolvable on the network)

I've noticed that currently, the StreamsKafkaClient just continues to retry it's connection to the unavailable servers, but never actually kills the start-up of the application.

How can I terminate the application if Kafka is unavailable?

John Giotta
  • 16,432
  • 7
  • 52
  • 82
  • I suppose you can kill the spring boot process by process id (in unix env)? Is that not working ? Please add some details about your env. – notionquest Jun 15 '18 at 15:09
  • No, you misunderstand. When a spring boot application is starting up it will attempt to connect to the kafka stack, but eventhough it throws a `java.net.ConnectException` it doesn't actually kill the application. It just continues to try to connect. – John Giotta Jun 15 '18 at 15:21
  • When I started to work with Kafka I had the same problem, even though I was not using Spring Boot I think you can follow the same approach. You can try simple things first before starting to consume the data, for example, ask for the list of topics: https://stackoverflow.com/questions/41016075/check-if-system-is-connected-to-kafka/47476774#47476774. – dbustosp Jun 16 '18 at 00:30
  • how about destroying the application context? https://stackoverflow.com/questions/22944144/programmatically-shut-down-spring-boot-application – Indraneel Bende Jun 17 '18 at 02:04
  • This is may be possible. The problem is `SpringApplication.run` never completes. I can get to some Application Events, but not the context to exit. – John Giotta Jun 18 '18 at 17:22

1 Answers1

0

Add this in your config

  factory.getContainerProperties().setMissingTopicsFatal(true);
Procrastinator
  • 2,526
  • 30
  • 27
  • 36
Kavita
  • 1