Migrate to the new chunk-oriented step model

MSAL

Spring Batch 6.0 deprecates StepBuilder.chunk(int, PlatformTransactionManager) in favor of a new chunk-oriented model. Replaces chunk(chunkSize, transactionManager) with chunk(chunkSize).transactionManager(transactionManager) when every other call in the builder chain has a counterpart on ChunkOrientedStepBuilder. A retryLimit(..) and the retry(..) calls in its chain become one retryPolicy(RetryPolicy) that keeps the number of attempts and has no delay, because the new model counts retryLimit as retries rather than attempts and, by default, waits one second between them. A retryLimit(..) without any retry(..) is removed, as the new model would otherwise retry every exception. Unlike Spring Retry, the new policy also retries when a cause of the thrown exception matches. Chains with advanced Spring Retry configuration are left untouched and remain a manual migration step: retryPolicy, backOffPolicy, retryContextCache, keyGenerator, noRetry and listener(RetryListener). The same applies to other APIs the new model dropped: listener(Object), noRollback, noSkip, processorNonTransactional, readerIsTransactionalQueue, chunkOperations, stepOperations, exceptionHandler, chunk(CompletionPolicy, PlatformTransactionManager) and taskExecutor(TaskExecutor) with a non-async executor. See the Spring Batch 6.0 migration guide.

org.openrewrite.java.spring.batch.MigrateToChunkOrientedStepBuilder
mod run . --recipe=org.openrewrite.java.spring.batch.MigrateToChunkOrientedStepBuilder

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.