Harsha Chittepu
Harsha Chittepu

Reputation: 125

Kafka Streams : when will StateRestoreListener gets called?

I have attached my kafka streams instance with an implementation of org.apache.kafka.streams.processor.StateRestoreListener interface. I have used Processor API to define my streams and it has a state store. Basically the job of streams is to read data from an input topic and store the data in state store.

I want to know under what situations this StateRestoreListener gets invoked.

Does it get invoked when I start streams for the first time?

Does it get invoked when I start another instance?

Does it get invoked when I stop certain instance?

and in each case .. what methods get invoke?

Upvotes: 0

Views: 410

Answers (1)

Matthias J. Sax
Matthias J. Sax

Reputation: 62350

Does it get invoked when I start streams for the first time?

No, because when you start for the first time the state store is empty and thus there is nothing to be restored.

Does it get invoked when I start another instance?

That would happen of part of the state is migrated to the newly started instance. The listener would be called on the new instance only, but not on the existing instance, because the existing instance does not need to restore anything.

Does it get invoked when I stop certain instance?

Yes, this is a similar case as the one above. The state of the stopped instance would be migrate to another (or multiple) still running instances, and those would restore the state and thus call the listener.

and in each case .. what methods get invoke?

All three methods would be invoked. The "start" and "end" callbacks once, and the third callback regularly during restore to report progress.

Upvotes: 2

Related Questions