Search code examples
akkakafka-consumer-apialpakka

What is the purpose of createDrainingControl?


I was reading through the documentation of Alpakka. While reading through Kafka consumer API, I came across createDrainingControl(), I was wondering what is the use for this function? I understand that this is used to drain and stop the stream, but why do we need to stop the stream if we are continuously consuming the messages from Kafka MQ?


Solution

  • Eventually you will want to deploy a new version of the application where you will have to stop the current application and start a new version of it. This can always be done by killing the old application, but that increases the number of replays, timeouts or errors, all depending of what you application does.

    If, instead you stop the application gracefully by draining the stream first, it decreases the amount of those irregularities.