Spring Integration DSL历史记录问题 [英] Spring Integration DSL History issue
本文介绍了Spring Integration DSL历史记录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须动态设置流程.
I have to setup the flows dynamically.
示例:
@Component
@Slf4j
public class FTPFlow {
@Autowired
private IntegrationFlowContext integrationFlowContext;
@EventListener(ApplicationReadyEvent.class)
public void setup(){
integrationFlowContext.registration(flow()).register();
}
public IntegrationFlow flow() {
DefaultFtpSessionFactory defaultFtpSessionFactory = new DefaultFtpSessionFactory();
defaultFtpSessionFactory.setHost("localhost");
defaultFtpSessionFactory.setPort(252);
defaultFtpSessionFactory.setUsername("user");
defaultFtpSessionFactory.setPassword("password");
return IntegrationFlows.from(Ftp.inboundAdapter(defaultFtpSessionFactory).preserveTimestamp(true)
.localDirectory(new File("D:/tools/input"))
.regexFilter("yo.txt")
.remoteDirectory("/testing")
.deleteRemoteFiles(true),
e -> e.poller(Pollers.fixedDelay(10, TimeUnit.SECONDS)))
.transform((GenericTransformer<File, File>) file -> {
log.info("Dummy transformer. ");
return file;
})
.handle(o -> {
log.info("history {}", o.getHeaders());
})
.get();
}
}
springboot应用程序:
The springboot application:
@SpringBootApplication
@EnableMessageHistory
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
标头不包含历史记录,但是如果我不使用IntegrationContext并直接在方法流上使用@Bean
,则可以看到历史记录.
The headers don't contain the history but if I don't use the IntegrationContext and use the @Bean
directly on the method flow then I can see the history.
使用IntegrationFlowContext
时是否必须启用历史记录?
Do I have to enable the history when using IntegrationFlowContext
?
推荐答案
我实际上是发现自己的.只是为其他人添加答案
使用IntegrationFlowContext
时,必须提供"id"
,否则历史记录不会保留.
When you are using IntegrationFlowContext
you have to provide the "id"
otherwise the history is not reserved.
integrationFlowContext.registration(flow()).id("tesflow").register();
这篇关于Spring Integration DSL历史记录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文