は私がItemReader
次があります:loadFile
が存在しない場合は@Retryable maxAttemptsを超えた後、Spring BatchのItemStreamExceptionを捕捉する方法は?
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.LineMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
@Service
public class MyReader extends FlatFileItemReader<Holding> {
@Autowired
public MyReader(LineMapper<Holding> lineMapper, File loadFile) {
setResource(new FileSystemResource(loadFile));
final int NUMBER_OF_HEADER_LINES = 1;
setLinesToSkip(NUMBER_OF_HEADER_LINES);
setLineMapper(lineMapper);
}
@Override
@Retryable(value=ItemStreamException.class, maxAttempts=5, [email protected](delay=1800000))
public void open(ExecutionContext executionContext) throws ItemStreamException {
super.open(executionContext);
}
}
は、第五試みの後、ItemStreamExceptionがスローされます。この例外はどのようにして捕捉できますか?
私は管理者に電子メールを送信することでこの例外を処理したいと考えています。私はtry catch節を使ってjobLauncher.run(job, jobParameters);
を試してみましたが、うまくいきません。