@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { assertNotSame(threadName, Thread.currentThread().getName()); Trade item = provider.read(); threadNames.add(Thread.currentThread().getName() + " : " + item); items.add("" + item); if (item != null) { processor.write(Collections.singletonList(item)); // Do some more I/O for (int i = 0; i < 10; i++) { TradeItemReader provider = new TradeItemReader(resource); provider.open(new ExecutionContext()); while (provider.read() != null) continue; provider.close(); } } return RepeatStatus.continueIf(item != null); } };
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { assertNotSame(threadName, Thread.currentThread().getName()); threadNames.add(Thread.currentThread().getName()); Thread.sleep(100); Trade item = provider.read(); if (item != null) { processor.write(Collections.singletonList(item)); } return RepeatStatus.continueIf(item != null); } };
@Override public RepeatStatus doInIteration(RepeatContext context) throws Exception { assertNotSame(threadName, Thread.currentThread().getName()); threadNames.add(Thread.currentThread().getName()); Thread.sleep(100); TradeItemReader provider = new TradeItemReader(resource); provider.open(new ExecutionContext()); while (provider.read() != null) ; return super.doInIteration(context); } };
@Before public void setUp() throws Exception { provider = new TradeItemReader(resource); provider.open(new ExecutionContext()); }
@Override public Trade read() throws Exception { if (count++ < 2) return provider.read(); return null; } };
protected TradeItemReader(Resource resource) throws Exception { super(); setResource(resource); DefaultLineMapper<Trade> mapper = new DefaultLineMapper<>(); mapper.setLineTokenizer(new DelimitedLineTokenizer()); mapper.setFieldSetMapper(new TradeMapper()); setLineMapper(mapper); afterPropertiesSet(); }