'SocketException : Broken Pipe (Write Failed) while using FlatFileItemReader in Spring Batch
I am using Spring - Batch FlatFileItemReader to read my input stream.
@Bean
@StepScope
public FlatFileItemReader<Employee> flatFileItemReader(){
InputStream inputStream = apiCallGetInputStream();
return new FlatFileItemReaderBuilder<Employee>().
.name("reader")
.resource(new InputStreamResource(inputStream))
.encoding("UTF-8")
.delimited()
.delimited("|")
.names("id","name","dept")
.linesToSkip(2)
.targetType(Employee.class)
.build();
}
public InputStream apiCallGetInputStream(){
InputStream inputStream = null;
try{
Url url=new URL("myUrl");
final HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
setConnectionParams();
inputStream = connection.getInputStream();
}catch(IOException ex){
log.error(ex);
}
return inputStream;
}
public void setConnectionParams(HttpsURLConnection connection){
connection.setRequestProperty("Content-type","application-json");
connection.setRequestMethod("GET");
connection.setReadTimeout(600000);
connection.setConnectTimeout(600000);
}
Please note : response I am getting is TXT format delimited with | character
ex:
Reading
Start
101|john|eng
201|maxwell|eng
301|amy|eng
After reading 80K records everytime suddenly I am getting
Caused by: javax.net.ssl.SSLException: Connection reset Suppressed: java.next.SocketException : Broken Pipe (Write Failed)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
