I am having the Web-service method to start spring batch job.If any exception occurred in spring batch processing control is coming back till processor process method. But i need the controller to came back to web-service method there i have to catch and code to email that exception.
Web-service method:
public void processInputFiles() throws ServiceFault {
String[] springConfig = { CONTEXT_FILE_NAME };
ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);
try {
setClientInfo();
JobLauncher jobLauncher = (JobLauncher) context.getBean(JOB_LAUNCHER);
Job job = (Job) context.getBean(REMITTANCE_JOB);
jobLauncher.run(job, new JobParameters());
}catch (Exception e) {
String errorMessage = "LockboxService exception:: Could not process Remittance(CSV) files";
final Message message = MessageFactory.createErrorMessage(MyService.class, errorMessage, e);
ErrorSenderFactory.getInstance().send(message, new Instruction[] { Instruction.ERROR_EMAIL });
}
Processor process method:
@Override
public Transmission process(InputDetail remrow) throws ServiceException {
try {
business logic here
}
catch(Exception e) {
throw new Exception("Unable to process row having the int number:");
}
}