I have a stream app with below driver code for real-time message transformation.
String topicName = ...
KStreamBuild
Kakfa 0.10.1.x
has some bugs with regard to multi threading. You can either upgrade to 0.10.2
(AK released today, CP 3.2 should follow shortly) or you apply the following workaround:
You might also need to delete your local state directory (only once) before restarting to get into a overall consistent application state.
In any case, there will be no data loss. Kafka Streams guarantees at-least-once processing semantics even in case of failure. This applies to you local stores too -- after you delete local state dir, on startup those state will be recreated from the underlying Kafka changelog topics (it an expensive operation though).
The UncaughtExceptionHandler
does only provide you a way to figure out that a thread died. It does not (directly) help to restart your application. To recover died threads, you need to close KafkaStreams
instance completely and create/start a new one. We hope to add better support for this in the future.