Spring Integration DSL History issue

本小妞迷上赌 提交于 2020-01-14 02:59:17

问题


I have to setup the flows dynamically.

Example:

@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();
    }
}

The springboot application:

@SpringBootApplication
@EnableMessageHistory
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

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.

Do I have to enable the history when using IntegrationFlowContext?


回答1:


I actually found out myself. Just adding answer for other people

When you are using IntegrationFlowContext you have to provide the "id" otherwise the history is not reserved.

 integrationFlowContext.registration(flow()).id("tesflow").register();


来源:https://stackoverflow.com/questions/59582449/spring-integration-dsl-history-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!