The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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 (47) [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