Jacek Laskowski (37) [Avatar] Offline
#1
Hi,

I can't seem to find the answer but in this blog post the author uses KafkaStreams.cleanUp.

Why would I want to do it? Could you show pros and cons of using the method? Should I be using it all the time or just infrequently and mostly for demo purposes?

Jacek
Bill Bejeck (44) [Avatar] Offline
#2
Hi Jacek,

Thanks for asking, it's a great question.

The KafkaStreams.cleanUp() method deletes all data in the local state store directory associated with the application id of the streams app making the call. You configure the directory used to store the data by setting the SteamsConfig.STATE_DIR_CONFIG property.

After you've called KafkaStreams.cleanUp(), the next time you start your Kafka Streams application a full restore of the State Store from the backing changelog topic is triggered. Hence if you have several state stores and or a significant amount of state, the restoration process could take a non-trivial amount of time, so you need to use the method judiciously.

You should also note that you can only call cleanUp before starting your application or after it has stopped.

So to answer your question about when to best use cleanUp, I would say it's suitable for unit and integration tests, local development, demos, etc.

I'll go back and make sure I thoroughly explain this in the book.

Thanks,
Bill