I am trying to schedule a task in one of my Kafka processors to delete records from a local KeyValueStore (RocksDB). Even though no exception has appeared so far, none of the records are getting deleted. Here is my code:
processorContext.schedule(Duration.ofHours(6), PunctuationType.WALL_CLOCK_TIME, timestamp -> {
store.all().forEachRemaining(keyValue -> {
// CommonUtil.removeOutdatedMessage(store,keyValue.key,keyValue.value.getSentAt());
LocalDateTime sentAt = null;
try {
sentAt = LocalDateTime.parse(keyValue.value.getSentAt(), DateTimeFormatter.ISO_OFFSET_DATE_TIME);
} catch (DateTimeException ex) {
LOGGER.warn("Parsing of date {} failed for message with: {}", keyValue.value.getSentAt(), ex);
}
if (sentAt == null) {
store.delete(keyValue.key);
} else {
boolean isExpired = sentAt.isBefore(LocalDateTime.now().minusDays(Constants.MESSAGE_EXPIRATION_LIMIT));
if (isExpired) {
store.delete(keyValue.key);
}
}
});
});
}