0

This is regarding Spring Batch - https://github.com/spring-projects/spring-batch/issues/1844, extending this question further here. I am looking to delete all history from Spring Batch metadata tables older than 30 days since its no longer needed to hold that info and this will save some space at db side.

How can we do this programmatically through Spring Batch code?

PAA
  • 1
  • 46
  • 174
  • 282
  • Does this answer your question? [Spring Batch Tables Purging](https://stackoverflow.com/questions/47233217/spring-batch-tables-purging) – Mahmoud Ben Hassine Feb 01 '21 at 08:59
  • @MahmoudBenHassine - Hey, thanks, I've seen this, but I am looking to do it through Spring Batch code and not through procedure ! – PAA Feb 01 '21 at 09:10
  • You seem to have stopped at the first answer. Check the link in this answer: https://stackoverflow.com/a/61646405/5019386: it shows a tasklet that does that. – Mahmoud Ben Hassine Feb 01 '21 at 09:17
  • I am sorry, I am looking to purge whole data older than 30 days - not by step wise purging. Could you please show some code to do that? – PAA Feb 01 '21 at 09:39
  • 1
    This tasklet from the linked answer deletes everything older than x months, not step wise: https://github.com/arey/spring-batch-toolkit/blob/master/src/main/java/com/javaetmoi/core/batch/tasklet/RemoveSpringBatchHistoryTasklet.java. It has a setter for `historicRetentionMonth`, which should be equal to 1 in your case (30 days). – Mahmoud Ben Hassine Feb 01 '21 at 09:45
  • Thanks, this is what I was looking for , – PAA Feb 01 '21 at 09:46

0 Answers0