【发布时间】:2020-12-15 13:27:53
【问题描述】:
我有一个使用 Java DSL 配置的集成流,它使用 Ftp.inboundChannelAdapter 从 Ftp 服务器提取文件,然后将其转换为 JobRequest,然后我有一个触发我的批处理作业的 .handle() 方法,一切都按要求工作但是对于 FTP 文件夹中的每个文件顺序运行的过程
我在我的 Transformer Endpoint 中添加了 currentThreadName,它为每个文件打印相同的线程名称
这是我到目前为止所尝试的
1.task执行器bean
@Bean
public TaskExecutor taskExecutor(){
return new SimpleAsyncTaskExecutor("Integration");
}
2.集成流程
@Bean
public IntegrationFlow integrationFlow(JobLaunchingGateway jobLaunchingGateway) throws IOException {
return IntegrationFlows.from(Ftp.inboundAdapter(myFtpSessionFactory)
.remoteDirectory("/bar")
.localDirectory(localDir.getFile())
,c -> c.poller(Pollers.fixedRate(1000).taskExecutor(taskExecutor()).maxMessagesPerPoll(20)))
.transform(fileMessageToJobRequest(importUserJob(step1())))
.handle(jobLaunchingGateway)
.log(LoggingHandler.Level.WARN, "headers.id + ': ' + payload")
.route(JobExecution.class,j->j.getStatus().isUnsuccessful()?"jobFailedChannel":"jobSuccessfulChannel")
.get();
}
3.我还在另一个 SO 线程中读到我需要 ExecutorChannel,所以我配置了一个,但我不知道如何将此通道注入我的 Ftp.inboundAdapter,从日志中看到该通道始终为 @987654329 @ 我猜是DirectChannel
@Bean
public MessageChannel inputChannel() {
return new ExecutorChannel(taskExecutor());
}
我不知道我在这里缺少什么,或者我可能没有正确理解 Spring 消息系统,因为我对 Spring 和 Spring-Integration 非常陌生
感谢任何帮助
谢谢
【问题讨论】:
标签: spring-integration spring-integration-dsl spring-integration-sftp