skip - How is the skipping implemented in Spring Batch? -
i wondering how determine in itemwriter, whether spring batch in chunk-processing-mode or in fallback single-item-processing-mode. in first place didn't find information how fallback mechanism implemented anyway.
even if haven't found solution actual problem yet, i'd share knowledge fallback mechanism you.
feel free add answers additional information if missed ;-)
the implementation of skip mechanism can found in faulttolerantchunkprocessor , in retrytemplate.
let's assume configured skippable exceptions no retryable exceptions. , there failing item in current chunk causing exception.
now, first of whole chunk shall written. in processor's write() method can see, retrytemplate called. gets 2 references retrycallback , recoverycallback.
switch on retrytemplate. find following method:
protected <t> t doexecute(retrycallback<t> retrycallback, recoverycallback<t> recoverycallback, retrystate state) there can see retrytemplate retried long it's not exhausted (i.e. once in our configuration). such retry caused retryable exception. non-retryable exceptions abort retry mechanism here.
after retries exhausted or aborted, recoverycallback called:
e = handleretryexhausted(recoverycallback, context, state); that's single-item-processing mode kick-in now!
the recoverycallback (which defined in processor's write() method!) put lock on input chunk (inputs.setbusy(true)) , run scan() method. there can see, single item taken chunk:
list<o> items = collections.singletonlist(outputiterator.next());
if single item can processed itemwriter correctly, chunk finished , chunkorientedtasklet run chunk (for next single items). cause regular call retrycallback, since chunk has been locked recoverytemplate, scan() method called immediately:
if (!inputs.isbusy()) { // ... } else { scan(contribution, inputs, outputs, chunkmonitor); } so single item processed , repeated, until original chunk has been processed item-by-item:
if (outputs.isempty()) { inputs.setbusy(false); that's it. hope found helpful. , more hope find via search engine , didn't waste time, finding out yourself. ;-)
Comments
Post a Comment