Bug 4281

Summary: Clarification needed around RetryListener methods
Product: jbatch Reporter: mminella
Component: sourceAssignee: cvignola
Status: CLOSED FIXED    
Severity: enhancement CC: issues, ScottKurz
Priority: P5    
Version: 1   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Whiteboard:

Description mminella 2012-11-09 21:27:47 UTC
In section 6.2.8, the interface for a RetryListener seems to have two methods for every event where I would expect only one.  For example, onRetryReadException and onRetryReadItem.  Both are called when a retryable exception is thrown on reading an item.  Both take the Exception that was thrown as the argument.  It is unclear what the difference between the two are and when to use each.  Same goes for onRetryProcessException/onRetryProcess and onRetryWriteException/onREtryWriteItems.
Comment 1 ScottKurz 2012-11-09 21:37:45 UTC
The flow outline in Sec. 8.7 do explain this in more detail.

The onRetryReadException is called immediately after the exception is caught, and the determination is made that it is one to retry upon.   

The onRetryReadItem is called before the read is performed again (retried).  

The one question I have:

In the retry-with-rollback case, are:
onRetryReadItem 
onRetryProcessItem
onRetryWriteItems

supposed to be called for every read/process/write in the rolled back checkpoint?   Or are they supposed to ONLY be called for the read/process/write corresponding to the original failure?

If the latter, there could be some subtleties to iron out, since for example, "process" might return a different item the second time..or filter differently.
Comment 2 cvignola 2012-11-19 13:27:47 UTC
The idea is that one is called in the same transaction as the error, while the other is called in the next transaction before the actual retry.  E.g. this sequence:

reader.readItem(...)
onRetryReadException(...)     
roll back
begin
onRetryRead(...)
reader.ReadItem(...) # again


(In reply to comment #0)
> In section 6.2.8, the interface for a RetryListener seems to have two methods
> for every event where I would expect only one.  For example,
> onRetryReadException and onRetryReadItem.  Both are called when a retryable
> exception is thrown on reading an item.  Both take the Exception that was
> thrown as the argument.  It is unclear what the difference between the two are
> and when to use each.  Same goes for onRetryProcessException/onRetryProcess and
> onRetryWriteException/onREtryWriteItems.
Comment 3 cvignola 2012-11-19 13:33:09 UTC
OnRetryWriteItems is problematic, because I think we intend to retry the chunk, reading one item at a time.  Maybe we should not have OnRetryRead/Process/WriteItem(s) methods. Just have the OnRetry*Exception methods and be done with it.  Thoughts?


(In reply to comment #1)
> The flow outline in Sec. 8.7 do explain this in more detail.
> The onRetryReadException is called immediately after the exception is caught,
> and the determination is made that it is one to retry upon.   
> The onRetryReadItem is called before the read is performed again (retried).  
> The one question I have:
> In the retry-with-rollback case, are:
> onRetryReadItem 
> onRetryProcessItem
> onRetryWriteItems
> supposed to be called for every read/process/write in the rolled back
> checkpoint?   Or are they supposed to ONLY be called for the read/process/write
> corresponding to the original failure?
> If the latter, there could be some subtleties to iron out, since for example,
> "process" might return a different item the second time..or filter differently.
Comment 4 cvignola 2012-11-19 13:34:18 UTC
I think we should not have OnRetryRead/Process/WriteItem(s) methods. Just have the OnRetry*Exception methods and be done with it.  Thoughts?
Comment 5 mminella 2012-11-19 15:20:35 UTC
I agree with the consolidation of it just down to when the exception is thrown.