Example usage for org.springframework.integration.ftp.dsl Ftp inboundStreamingAdapter

List of usage examples for org.springframework.integration.ftp.dsl Ftp inboundStreamingAdapter

Introduction

In this page you can find the example usage for org.springframework.integration.ftp.dsl Ftp inboundStreamingAdapter.

Prototype

public static FtpStreamingInboundChannelAdapterSpec inboundStreamingAdapter(
        RemoteFileTemplate<FTPFile> remoteFileTemplate) 

Source Link

Document

A FtpStreamingInboundChannelAdapterSpec factory for an inbound channel adapter spec.

Usage

From source file:org.springframework.integration.ftp.dsl.FtpTests.java

@Test
public void testFtpInboundStreamFlow() throws Exception {
    QueueChannel out = new QueueChannel();
    StandardIntegrationFlow flow = IntegrationFlows.from(
            Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sessionFactory()))
                    .remoteDirectory("ftpSource").regexFilter(".*\\.txt$"),
            e -> e.id("ftpInboundAdapter").poller(Pollers.fixedDelay(100))).channel(out).get();
    IntegrationFlowRegistration registration = this.flowContext.registration(flow).register();
    Message<?> message = out.receive(10_000);
    assertNotNull(message);/*from  w w  w  .j  a  v  a 2s.c  om*/
    assertThat(message.getPayload(), instanceOf(InputStream.class));
    assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf(" ftpSource1.txt", "ftpSource2.txt"));
    new IntegrationMessageHeaderAccessor(message).getCloseableResource().close();

    message = out.receive(10_000);
    assertNotNull(message);
    assertThat(message.getPayload(), instanceOf(InputStream.class));
    assertThat(message.getHeaders().get(FileHeaders.REMOTE_FILE), isOneOf(" ftpSource1.txt", "ftpSource2.txt"));
    new IntegrationMessageHeaderAccessor(message).getCloseableResource().close();

    registration.destroy();
}