Search code examples
spring-kafka

what is controlledShutdown in embeddedKafka


Does anyone know what "controlledShutdown" means in embeddedKafka and how it (true / false) affects the test execution?

https://docs.spring.io/spring-kafka/api/org/springframework/kafka/test/EmbeddedKafkaBroker.html#%3Cinit%3E(int,boolean,int,java.lang.String...)

I did try to find the answer. but no luck :(


Solution

  • This is essentially a flag the EmbeddedKafkaBroker propagates to the kafka.utils.TestUtils.createBrokerConfig(). Which is set as a KafkaConfig.ControlledShutdownEnableProp().

    So, now we go to the Apache Kafka Broker docs and see what is that about: https://subscription.packtpub.com/book/big-data-and-business-intelligence/9781787286849/1/ch01lvl1sec21/configuring-other-miscellaneous-parameters

    controlled.shutdown.enable: Default value: true. If this value is true, when a shutdown is called on the broker, the leader will gracefully move all the leaders to a different broker. When it is true, the availability is increased.

    You can see there are other useful props to set as well: controlled.shutdown.max.retries, controlled.shutdown.retry.backoff.ms etc.