Search code examples
javaspringspring-integrationspring-integration-dsl

Configure a directory scanner on an inbound channel with Spring Integration Java DSL on Spring Integration 5


So Spring Integration 5 introduced the concept of a directory scanner for inbound channels and I'm keen to use this with my ftp channel.

However I'm not sure how to configure it with Java DSL. The docs say I can set the scanner on the scanner inbound-channel-adapter in xml. However, I'm using Spring Integration DSL via IntegrationFlow and it appears that I have no way of setting this directory scanner when taking this approach...

Is this true? Is there a way I can set the directory scanner with IntegrationFlow. I know I can move to using a more formal Java Config approach but I'd prefer not to as that would be a lot of work.


Solution

  • Looks like we have just missed to add a scanner option to the DSL.

    However here is a simple workaround for you:

        FtpInboundFileSynchronizingMessageSource ftpSource =
                Ftp.inboundAdapter(sessionFactory())
                        .regexFilter(".*\\.txt$")
                        .get();
        ftpSource.setScanner(...);
        IntegrationFlow flow = IntegrationFlows.from(ftpSource,
    

    So, what you need is to extract a target object from the DSL Spec and call its setter directly.

    Feel free to contribute the .scanner() option into the RemoteFileInboundChannelAdapterSpec back to the Framework!