Spring Batch DeadlockLoserDataAccessException

对着背影说爱祢 提交于 2019-12-24 18:19:43

问题


I'm using Spring Batch with partitioning. Initially, I was getting DeadlockLoserDataAccessException and then I have configured our steps as faultTolerant, please see the following code -

Step masterCalculationStep = stepBuilderFactory.get("STEP_1")
                   .<Map<Long, List<CostCalculation>>, List<TempCostCalc>>chunk(1).reader(reader)
                   .processor(processor)
                   .writer(writer)
                   .faultTolerant()
                   .retryLimit(5)
                   .retry(DeadlockLoserDataAccessException.class)
                   .build();

but now we are getting another exception -

org.springframework.batch.core.step.skip.NonSkippableReadException: Non-skippable exception during read

Don't know why this new exception and how to resolve it?


回答1:


The RetryPolicy in a chunk oriented step is not applied to the reader. So if your reader might throw a transient exception, you need to add the retry logic around the reader yourself. This can be done for example with:

  • AOP by applying org.springframework.retry.interceptor.RetryOperationsInterceptor to your reader
  • or by using org.springframework.retry.support.RetryTemplate in a decorator of your reader that reties the read method when it throws a transient exception

Similar questions can be found here:

  • Spring batch retry mechanism for reader failure
  • Retry in case of a failed reading

Hope this helps.



来源:https://stackoverflow.com/questions/54902312/spring-batch-deadlockloserdataaccessexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!