0

I am using Spring Integration Java DSL v. 1.2.2 and following some examples I try to write a code to poll a folder

    return IntegrationFlows
            .from(Files.inboundAdapter(new File("/tmp/foo")))
            .handle((p, h) -> fileProcessor.process(p))
            .get();

This code can not be compiled because

"Cannot resolve method 'from(org.springframework.integration.dsl.
   file.FileInboundChannelAdapterSpec)'"

How this can be fixed and how fixed-interval polling can be added?

onkami
  • 8,791
  • 17
  • 90
  • 176

1 Answers1

1

Not clear what's going on in your IDE, but we have this sample in test-cases:

@Bean
public IntegrationFlow fileToFile() {
    return IntegrationFlows.from(Files.inboundAdapter(new File("/tmp/in"))
                    .autoCreateDirectory(true)
                    .patternFilter("*.txt"),
            e -> e.poller(Pollers.fixedDelay(5000)))
            .transform(Transformers.fileToString())
            .transform("payload.replaceAll('\r\n', '\n')")
            .handle(Files.outboundAdapter("'/tmp/out'")
                    .autoCreateDirectory(true))
            .get();
}

The fixedDelay() is an answer to your second question about fixed-interval.

https://github.com/spring-projects/spring-integration-java-dsl/blob/master/src/test/java/org/springframework/integration/dsl/samples/file2file1/FileChangeLineSeparator.java

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Artem, can you please clarify what dependences I should use? I now had to use compile("org.springframework.boot:spring-boot-starter-integration:1.5.4.RELEASE") and I had to use direct typecats IntegrationFlows.from((MessageSourceSpec, ? extends MessageSource>>) Files.inboundAdapter(directory) - and still getting Linking error nowError:(105, 38) java: cannot access org.springframework.integration.file.FileReadingMessageSource not found. – onkami Jun 14 '17 at 09:43
  • Spring integration doc seems really bad when it comes to adding DSL support in dependences. It only suggests adding compile("org.springframework.integration:spring-integration-core:4.3.10.RELEASE") that is not including DSL. – onkami Jun 14 '17 at 09:46
  • 1
    You have to add `Spring-Integration-file`. Each module in Spring Integration is separate jar, dependency artifact – Artem Bilan Jun 14 '17 at 11:54