My stateful function is writing data to a database, but it is nondeterministic so restoring from a checkpoint can result in the database containing inconsistent data. My idea is to 'buffer' data in Flink's persistent state and only write the data to the database once a checkpoint has finished. I guess I could sort of achieve this by using context.sendAfter(Duration duration, Address address, Object input);
, by setting the duration higher than the checkpointing interval.
Is there a better solution available that would enable the function to react to checkpoints explicitly?