Write to GlobalStateStore on Kafka Streams

偶尔善良 提交于 2020-06-28 06:22:38

问题


I am trying to use addGlobalStore on a Kafka DSL where a need to store few values that I will need global access for all my threads/instances.

My problem is that I need periodically to update these values inside my topology and make all running threads aware of the new values.

I initialized the global store through builder.addGlobalStore and using the init() function of a Processor that was used as the last argument on this function, but I cannot find a way to update the values inside the global store.

The next step on my Topology is a Transformer where I can get a hook through ```init()`` on the global Store and read the stored values but unfortunately I cannot updated them globally. I mean I can update the local copy for the running thread but other threads/instances cannot see the change.

I read somewhere that this cannot be done on Transformer, but even I use a Processor instead the issue remains

So, Is there a way to update globalStateStore on a Kafka DSL topology, and if so how is this possible ? Or in order to use global store do I need to use the low level processor API ?


回答1:


I initialized the global store through builder.addGlobalStore and using the init() function of a Processor that was used as the last argument on this function, but I cannot find a way to update the values inside the global store.

You cannot update a global store directly. Instead, you must update (= write a message to) the underlying topic of that global store.




回答2:


In case it fits your needs you probably could use GlobalKTable instead of GlobalStore



来源:https://stackoverflow.com/questions/56239980/write-to-globalstatestore-on-kafka-streams

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!