我有一个工作的spring集成配置,如下所示:
@Configuration
@EnableIntegration
public class MyIntegrationConfiguration {
@Value("${watch.folder}")
private String watchFolder;
@Autowired
private ApplicationContext context;
@Bean
public MessageChannel myFileChannel() { return new DirectChannel(); }
@Bean
@InboundChannelAdapter(value = "myFileChannel", poller = @Poller(fixedDelay = "10000"))
public MessageSource<File> fileReadingMessageSource() {
FileReadingMessageSource source = new FileReadingMessageSource();
source.setDirectory(new File(watchFolder));
source.setFilter(new SimplePatternFileListFilter("trigger.txt"));
source.setScanEachPoll(true);
source.setUseWatchService(true);
return source;
}
@Transformer(inputChannel = "myFileChannel", outputChannel = "startProcessingJob")
public JobLaunchRequest transform(File triggerFile) {
String fileName = triggerFile.getAbsolutePath();
JobParameters jobParameters = new JobParametersBuilder()
.addString("fileName", fileName)
.addDate("dateTime", new Date())
.toJobParameters();
Job job = context.getBean("processFilesJob", Job.class);
JobLaunchRequest request = new JobLaunchRequest(job, jobParameters);
return request;
}
@Bean
@ServiceActivator(inputChannel = "startProcessingJob", outputChannel = "nullChannel")
protected JobLaunchingMessageHandler launcher(JobLauncher jobLauncher) {
return new JobLaunchingMessageHandler(jobLauncher);
}
}
此配置基本上监视应用程序属性“watch.folder”中指定的目录。当文件到达时,它启动一个spring批处理作业。
现在我的客户想添加一个新的功能,用户可以在网页中输入一个新的目录名,这基本上是收集一个新的教学信息,在保存新的租户数据的应用程序应该创建一个新的目录,并开始观看。
所以基本上我需要创建一个新的“inboundchanneladapter”,点击按钮并设置source.setdirectory(新文件(newfolderenteredviawebpage));
有没有关于如何使用spring集成来实现这一点的想法。
暂无答案!
目前还没有任何答案,快来回答吧!