Hi lucasward,
I made a minor change on Trade class of retrySample job to reproduce the issue. and I attached them.
After debugging the code, I found out the issue that might relate to ItemKeyGenerator. Our situation is that we need to generate a new id for trade in ItemWriter.write(), if exception happens when we write code to db, we will generate another id for it during retry.
But the code in ItemWriterRetryPolicy.hasFailed uses the trade itself as the key, that cause the infinite loop since it cannot find out the previous trade from retryContextCache due to trade.id has been changed.
I guess this issue may be the same one of http://jira.springframework.org/browse/BATCH-537
Cheers,
David
Code:
protected boolean hasFailed(FailedItemIdentifier failedItemIdentifier, ItemKeyGenerator keyGenerator, Object item) {
if (failedItemIdentifier != null) {
return failedItemIdentifier.hasFailed(item);
}
return retryContextCache.containsKey(keyGenerator.getKey(item));
}