Bug 4150

Summary: Difference between @OnRetryReadException and @OnRetryReadItem
Product: jbatch Reporter: ScottKurz
Component: sourceAssignee: cvignola
Status: CLOSED FIXED    
Severity: minor CC: issues
Priority: P5    
Version: 1   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Working copy of RI XSD

Description ScottKurz 2012-09-26 15:41:42 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???
Comment 1 ScottKurz 2012-09-26 20:48:07 UTC
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.

We have:

@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.
Comment 2 ScottKurz 2012-09-27 14:15:43 UTC
Created attachment 62 [details]
Working copy of RI XSD
Comment 3 cvignola 2012-10-05 20:12:36 UTC
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.
Comment 4 cvignola 2013-01-16 16:34:43 UTC
onRetryReadException was kept;  onRetryReadItem was removed