Bugzilla – Bug 4150
Difference between @OnRetryReadException and @OnRetryReadItem
Last modified: 2013-01-16 23:06:03 UTC
Why are there two methods here? I'm not following...
Clearly the first is supposed to be called before the second, but you seem to be trying to be saying something about the tran scope.
For the latter, we say,
"If the exception is a non-rollback exception, this method receives control in the same transaction scope as the item reader."
So you mean the same tran scope as the original item reader's read, right? Even for a retryable exception with rollback, of course it's going to be the same tran as the retried read.
Is one key point that for a retryable exception with rollback, the @OnRetryReadException only gets called once, but the @OnRetryReadItem gets called once for each item as we retry the whole chunk, one record at a time???
Another couple follow-up questions:
Does calling of @OnRetryReadItem happen instead of or in addition to @BeforeRead? (Since @AfterRead doesn't have a retry analogue I'm guessing
it happens in addition to @BeforeRead... probably before @BeforeRead).
What about @OnReadError? Does that get called before any skip or retry processing (or only if it's NOT skipped or retried?) Before @OnRetryReadException gets called then?
One more point which maybe ideally would be listed as a separate issue but you might prefer to deal with it with these others.
@OnReadError void <method-name> (Exception ex) throws Exception
Since Java has different meanings for Error vs. Exception and since we have specific exception-handling behavior.. it might be better to name this:
Or.. if you really intend any Throwable to result in a call maybe:
@OnReadError void <method-name> (Throwable t) throws Throwable
but I think only handling Exception(s) is better.
Created attachment 62 [details]
Working copy of RI XSD
This is a prime example of where a flow diagram would help. I will try to improve the spec. Here's the short answer:
1) @OnRetryReadException is invoked by the container immediately after the item reader throws a retryable exception. This is always the same transaction scope as the one in which the item reader was running when the exception occurred.
2) The batch container rolls back the current transaction and starts new scope.
3) @OnRetryReadItem is invoked in new transaction scope.
Note: that step #2 can be skipped by specifying the retryable exception is also a no-rollback-exception.
onRetryReadException was kept; onRetryReadItem was removed