Correct way to restart or shutdown the stream using UncaughtExceptionHandler

后端 未结 1 1122

I have a stream app with below driver code for real-time message transformation.

String topicName = ...
KStreamBuild         


        
1条回答
  •  执笔经年
    2021-01-02 17:50

    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:

    • use single thread execution only
    • if you need more thread, start more instances
    • for each instance, configure a different state directory

    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.

    0 讨论(0)
提交回复
热议问题