Reputation: 21
I am not able to understand how to save the data to globalKTable. I tried creating the GlobalKTable in java using
GlobalKTable globalTable = builder.globalTable(inputTopic, Materialized.>as("global-store"));
after this i am not able to find any example which stores data to this GlobalKTable directly. everywhere it is either used with joins or streams.
Upvotes: 2
Views: 1881
Reputation: 15087
I am not able to understand how to save the data to globalKTable. [...] i am not able to find any example which stores data to this GlobalKTable directly.
Today, you cannot directly write to a GlobalKTable
. You can only mutate a global table indirectly by writing events/records/messages to the topic from which the global table is populated from.
Upvotes: 2
Reputation: 1366
Since each Stream application instance loads the whole GlobalKTable
data, it disables logging to changelog
topic by default, and the GlobalKTable
uses the input topic as changelog source for restore process (to achieve fault tolerance) so it doesn't make sense to change the global store and you can't do that.
You can get read-only access to the global state in Processor API by using ProcessorContext.getStateStore("global-store")
without the need to add the store to Processor
.
One way you can achieve this is to push the updates you want to make to the inputTopic
so it updates each GlobalKTable across all application instances.
Upvotes: 4