@Component
public class NaverSportNewsTitleSkipPolicy implements SkipPolicy {
@Override
public boolean shouldSkip(Throwable throwable, long skipCount) throws SkipLimitExceededException {
if(throwable instanceof DataIntegrityViolationException){
return true;
}
return false;
}
}
@Component
@RequiredArgsConstructor
public class NaverSportNewsTitleSkipListener<T, S> implements SkipListener<T, S> {
private final JdbcTemplate jdbcTemplate;
@Override
public void onSkipInRead(Throwable t) {
jdbcTemplate.update("INSERT INTO NAVER_SPORT_NEWS_TITLE_ERROR (error) VALUES(?)", t.getMessage());
}
@Override
public void onSkipInWrite(S item, Throwable t) {
jdbcTemplate.update("INSERT INTO NAVER_SPORT_NEWS_TITLE_ERROR (error) VALUES(?)", t.getMessage());
}
}