Processor.close() 的 JavaDoc 说明在 Kafka 1.0.1 中说:
Note: Do not close any streams managed resources, like StateStores here, as they are managed by the library.
此外,StateStore.close() 的 JavaDoc 描述说,那:
Users only need to implement this function but should NEVER need to call this api explicitly as it will be called by the library automatically when necessary
但我在 documentation 中找到了一个示例,其中状态存储在该方法内被显式关闭:
@Override
public void close() {
// close the key-value store
kvStore.close();
}
所以,我有点迷路了。我是否应该关闭 Processor
中的状态存储?
最佳答案
不,你不应该关闭商店。
示例代码片段是错误的。感谢您指出。我打开了一个 PR 来修复它:https://github.com/apache/kafka/pull/4667
关于java - Kafka Streams 关闭处理器的状态存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49181359/