0

I have jobs in Spring Batch that are launched without parameters. This jobs are not restartable, so we use the -next argument and a JobParametersIncrementer to allow the execution of these jobs as a new execution each time. The -next argument needs to load all executionContexts to get the new unique JobParameters with the incrementer (CommandLineJobRunner line 492). The problem is that sometimes, a new release can change an object stored in the execution context, and the last execution context can become unserializable with the new release.

Is there a good way or a better practice to launch a job without parameters and allow changes in objects stored in the execution context ? Do we have to clear the repository history at every releases to avoid any failure, or is there a better solution ?

Johann Goulley
  • 405
  • 14
  • 25
  • Possible duplicate of https://stackoverflow.com/questions/49625231/migration-to-spring-boot-2-and-using-spring-batch-4 – Mahmoud Ben Hassine Jan 17 '19 at 08:46
  • It's not about a change in spring batch version like in the question suggested. It's about a change on an object in my custom application. I don't think it's a duplicate. – Johann Goulley Jan 17 '19 at 12:06
  • A solution I tried is to use a fake parameter like "run.date=" with the time in millisecond, which is always unique. We will probably choose this solution. – Johann Goulley Jan 17 '19 at 12:11
  • ok in that case, if the object structure changes, it is possible that the serialized version does not match the new version when it is deserialized, do you agree? But here we are talking about user defined objects stored in the execution context, while the question is about job parameters if I'm not mistaken (`better practice to launch a job without parameters`). In regards to your last comment, you can use the `RunIdIncrementer`. – Mahmoud Ben Hassine Jan 17 '19 at 12:15
  • The RunIdIncrementer is what we already use with the -next argument. Maybe it's already the best practice, and it needs a special attention to the evolutivity of the objects put in execution context. – Johann Goulley Jan 18 '19 at 09:31

0 Answers0