Announcement Announcement Module
Collapse
No announcement yet.
Read and Write Skip Behaviou Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Read and Write Skip Behaviou

    I have a job that reads a flat file of 11 records. I skip 1 item in reader and 4 in writers. I have one Skiplistener with SkipInRead() and SkipInWrite() method which simple logs the skip message in DB. Why my onSkipInRead is being called multiple times i.e. 3 times in this case which in result logs same message in DB 3 times. OnSkipinWrite works fine

    Code:
    <job id="ex_Job">
    		<step id="load">
    			<tasklet>
    				<chunk reader="reader" writer="writer" commit-interval="3" skip-limit="10">
    					<skippable-exception-classes>
    						<include class="org.springframework.batch.item.file.FlatFileParseException" />
    						<include class="org.springframework.batch.item.file.transform.IncorrectLineLengthException" />
    						<include class="org.springframework.dao.DataIntegrityViolationException"/>
    					</skippable-exception-classes>
    				</chunk>
    				<listeners>
    					<listener ref="genericSkipListener" />
    				</listeners>
    			</tasklet>
    		</step>
    	</job>
    	
    	
    	
    	public class GenericSkipListener extends AbstractBaseSkipListener implements
            SkipListener<FieldSet, FieldSet> {
    
        private static final Log LOGGER = LogFactory.getLog(GenericSkipListener.class);
    
        @Autowired
        private SkipedItemsDao skipedItemsDao;
    
    
        @Override
        public void onSkipInRead(final Throwable t) {
            LOGGER.warn("[" + getJobName() + "] onSkipInRead:" + t);
            skipedItemsDao.saveReadSkippedItem(createReadSkipedItem("READ", "", t));
        }
    
        @Override
        public void onSkipInWrite(final FieldSet item, final Throwable t) {
            LOGGER.warn("[" + getJobName() + "] onSkipWrite:" + t);
            skipedItemsDao.save(createSkipedItem("WRITE", item.toString(), t));
        }
    
        @Override
        public void onSkipInProcess(final FieldSet item, final Throwable t) {
            LOGGER.warn("[" + getJobName() + "] onSkipInProcess:" + t);
            skipedItemsDao.save(createSkipedItem("PROCESS", item.toString(), t));
        }
    	}
    My onSkipInRead() method is being call multiple times for the same item. Any idea guys ?
    Last edited by amique; Feb 24th, 2012, 01:31 AM.

  • #2
    Any idea guys

    Comment

    Working...
    X