【发布时间】:2020-01-19 16:59:16
【问题描述】:
您好,我有一个文件侦听器,它一次读取并行/多个文件
package com.example.demo.flow;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.dsl.*;
import org.springframework.integration.dsl.channel.MessageChannels;
import org.springframework.integration.file.dsl.Files;
import org.springframework.stereotype.Component;
import java.io.File;
import java.util.concurrent.Executors;
/**
* Created by muhdk on 03/01/2020.
*/
@Component
@Slf4j
public class TestFlow {
@Bean
public StandardIntegrationFlow errorChannelHandler() {
return IntegrationFlows.from("testChannel")
.handle(o -> {
log.info("Handling error....{}", o);
}).get();
}
@Bean
public IntegrationFlow testFile() {
IntegrationFlowBuilder testChannel = IntegrationFlows.from(Files.inboundAdapter(new File("d:/input-files/")),
e -> e.poller(Pollers.fixedDelay(5000L).maxMessagesPerPoll(5)
.errorChannel("testChannel")))
.channel(MessageChannels.executor(Executors.newFixedThreadPool(5)))
.transform(o -> {
throw new RuntimeException("Failing on purpose");
}).handle(o -> {
});
return testChannel.get();
}
}
它不会进入我的自定义错误通道
但如果我删除该行
.channel(MessageChannels.executor(Executors.newFixedThreadPool(5)))
然后进入错误通道。
我怎样才能让它工作,以便它通过执行程序进入我的自定义错误通道。
【问题讨论】:
标签: java spring-boot spring-integration spring-integration-dsl spring-integration-file