简体   繁体   English

在 Spring Integration 5 上使用 Spring Integration Java 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.所以 Spring Integration 5 为入站通道引入了目录扫描器的概念,我很想在我的 ftp 通道中使用它。

However I'm not sure how to configure it with Java DSL.但是我不确定如何使用 Java DSL 配置它。 The docs say I can set the scanner on the scanner inbound-channel-adapter in xml. 文档说我可以在 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...但是,我正在通过 IntegrationFlow使用Spring Integration DSL,并且在采用这种方法时,我似乎无法设置此目录扫描程序...

Is this true?这是真的? Is there a way I can set the directory scanner with IntegrationFlow.有没有办法可以使用 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.我知道我可以转而使用更正式的 Java Config 方法,但我不希望这样做,因为那将是很多工作。

Looks like we have just missed to add a scanner option to the DSL.看起来我们刚刚错过了向 DSL 添加scanner选项。

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.所以,你需要的是从 DSL Spec 中提取一个目标对象并直接调用它的 setter。

Feel free to contribute the .scanner() option into the RemoteFileInboundChannelAdapterSpec back to the Framework!随意将.scanner()选项贡献到RemoteFileInboundChannelAdapterSpec回框架!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM