Hi All,
I'm writing a simple application that uses both spring-integration and spring-batch. The app polls a directory, moves the found file into a 'processing' directory and then launches the batch job using the file. On completion of the job, the file is moved into the 'processed' directory.
My integration context looks like this:
fileToJobLaunchRequestAdapter snippet:Code:<int-file:inbound-channel-adapter directory="${file.input.directory}" channel="filesIn" filename-pattern="${file.filename.pattern}"> <int:poller cron="${file.poller.cron}" max-messages-per-poll="1" /> </int-file:inbound-channel-adapter> <int:channel id="filesIn" /> <int-file:outbound-gateway id="moveFileToProcessing" request-channel="filesIn" reply-channel="processing" directory="${file.processing.directory}" delete-source-files="true" /> <int:channel id="processing"> <int:dispatcher load-balancer="none" /> </int:channel> <int:chain input-channel="processing" order="1"> <int:service-activator ref="fileToJobLaunchRequestAdapter" method="adapt" /> <int:service-activator ref="jobLaunchingMessageHandler" method="launch" /> </int:chain> <int-file:outbound-channel-adapter order="2" directory="${file.processed.directory}" channel="processing" delete-source-files="true" />
jobLaunchingMessageHandler snippet:Code:@ServiceActivator public JobLaunchRequest adapt(File file) throws NoSuchJobException { JobParameters jobParameters = new JobParametersBuilder().addString("INPUT_FILE_PATH_KEY", file.getAbsolutePath()).toJobParameters(); return new JobLaunchRequest("job", jobParameters); }
spring.integration.version : 2.1.3.RELEASECode:@Autowired private JobLauncher jobLauncher; @Autowired private JobRegistry jobRegistry; @ServiceActivator public JobExecution launch(JobLaunchRequest request) throws NoSuchJobException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException { Job job = jobRegistry.getJob(request.getJobName()); JobParameters jobParameters = request.getJobParameters(); return jobLauncher.run(job, jobParameters); }
spring.batch.version : 2.1.9.RELEASE
All seems to work ok in the nominal case. However, if a runtime exception occurs in the batch job i'm unable to handle it with the current configuration. Can someone suggest how i might do this?
Any help appreciated.


Reply With Quote
