简体   繁体   English

使用apachecamel将文件从ftp移动到本地

[英]move file from ftp to local using apachecamel

I am new to Apachecamel I have a requirement to move a file from ftp location to my local folder: 我是Apachecamel的新手,我需要将文件从ftp位置移动到本地文件夹:

I am using below route to do this: 我正在使用下面的路线来做到这一点:

import java.io.File;

import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

public class CopyFtp {
    public static void main(final String[] arguments) {
        final CamelContext camelContext = new DefaultCamelContext();
        /*
         * ConnectionFactory connectionFactory = new
         * ActiveMQConnectionFactory("admin", "admin",
         * ActiveMQConnection.DEFAULT_BROKER_URL);
         * camelContext.addComponent("test-jms",
         * JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
         */
        try {
            camelContext.addRoutes(new RouteBuilder() {
                @Override
                public void configure() throws Exception {

                    from("ftp://user@server.com/folder?password=abc&delay=10000").routeId("testRoute")
                            .process(new Processor() {

                                @Override
                                public void process(Exchange msg) throws Exception {
                                    File file = msg.getIn().getBody(File.class);
                                    String file1 = msg.getIn().getBody(String.class);
                                    System.out.println("" + file + file1);
                                }

                            }).to("file://E:/TestingWatch1/output");

                }
            });
            camelContext.start();
            // Thread.sleep(10*60*1000);
            // camelContext.stop();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

I don't see file is moving from FTP location to my local folder, am I missing something here? 我没有看到文件从FTP位置移动到本地文件夹,我在这里丢失了什么吗?

In your case program is finished before context event fully started as there are no blocking there. 在您的情况下,在上下文事件完全开始之前,程序已完成,因为那里没有阻塞。 Here you can see how to run it properly and leave running: http://camel.apache.org/running-camel-standalone-and-have-it-keep-running.html 在这里,您可以查看如何正常运行并保持运行状态: http : //camel.apache.org/running-camel-standalone-and-have-it-keep-running.html

暂无
暂无

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

相关问题 如何使用Java将文件从ftp服务器下载到本地计算机 - How to download a file from ftp server to local machine using java 使用Java将文件从FTP服务器下载到本地 - Download a file from FTP server to local in java 使用Java将文件从FTP下载到本地会使文件不可读-编码问题 - Downloading files from FTP to local using Java makes the file unreadable - encoding issues 如何使用talend检查从ftp站点检索的文件是否存在于java的本地文件夹中? - How to check if a file retrieved from the ftp site exists in the local folder in java using talend? 将文件从一台ftp服务器复制或移动到另一台ftp服务器 - copy or move a file from one ftp server to another 如何使用Java将文件从本地计算机上传到Web服务以进行ftp传输? - How can I upload a file from my local machine to a webservice for ftp transfer using java? 使用Java DSL成功进行ftp传输后移动文件 - Move file after successful ftp transfer using Java DSL 在ApacheCamel中已在资源本地的EntityManager上调用joinTransaction - joinTransaction has been called on a resource-local EntityManager in ApacheCamel 在Java FTP中-是否可以在不使用本地文件的情况下使用ftp将文件压缩到远程位置? - In Java FTP-Can we compress a file in remote location using ftp, without bringing the file to local machine? 将动态递增的日志文件数据从FTP复制到本地 - Copy the dynamically incrementing log file data from FTP to local
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM