itemWriter에서 writer를 처리하다가 에러 발생시에 job 실패 처리하는 방법
@Slf4j
@Component
public class HelloItemWriter implements ItemWriter<Person>, StepExecutionListener {
private ExitStatus exitStatus = null;
@Override
public void write(List<? extends Person> items) throws Exception {
if(items.size() < 1) {
exitStatus = ExitStatus.FAILED;
}
}
@Override
public void beforeStep(StepExecution stepExecution) {}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
return exitStatus;
}
}
@Slf4j
@Component
public class HelloItemWriter implements ItemWriter<Person>, StepExecutionListener {
private ExitStatus exitStatus = null;
@Override
public void write(List<? extends Person> items) throws Exception {
if(items.size() < 1) {
exitStatus = ExitStatus.FAILED;
}
}
@Override
public void beforeStep(StepExecution stepExecution) {}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
return exitStatus;
}
}
댓글
댓글 쓰기