1

i recently started to use Spring Integration and i am facing a problem to upload a file to my ftp server. When i try to send the file using the command send nothing happens, and the program execution is stopped. Could anynone please help me? Tks a lot!

Here are the sources:

FtpOutbound-context.xml

<bean id="ftpClientFactory" class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
    <property name="host" value="xxxx"/>
    <property name="port" value="xxx"/>
    <property name="username" value="xxxxx"/>
    <property name="password" value="xxxxx"/>
</bean> 

<int-ftp:outbound-channel-adapter
            session-factory="ftpClientFactory"
            channel="ftpChannel"                        
            remote-directory="/xxxx/xx/"
            remote-filename-generator-expression="headers[fileName]">
</int-ftp:outbound-channel-adapter>

<int:channel id="ftpChannel"/>

UploadServiceApplication.java

public void run(ApplicationArguments args) throws Exception {

    ConfigurableApplicationContext ctx =
            new ClassPathXmlApplicationContext("META-INF/spring/integration/FtpOutbound-context.xml");
    MessageChannel ftpChannel = ctx.getBean("ftpChannel", MessageChannel.class);

    File file = new File("C:/Desenvolvimento/teste.txt");

    final Message<File> messageFile = MessageBuilder.withPayload(file).setHeader("fileName", file.getName()).build();
    ftpChannel.send(messageFile);

    Thread.sleep(2000);
}

0 Answers0