3

いくつかのファイルをローカル ディレクトリにダウンロードするための ftp クライアントを作成するために apache camel を使用しています。このプログラムは xml ファイルを読み取り、ftp からフェッチされるファイルの名前を取得します。プログラムは、ダウンロードされたファイルが破損していることを除けば動作しているようです。現在、いくつかの画像ファイルをダウンロードしようとしていますが、取得したファイルは 14.9Kb で破損しており、エラー メッセージは表示されません。

これは私のコードです:

主要

    public void main() throws FileNotFoundException {
        BasicConfigurator.configure();
        RutaFtp routeBuilder = new RutaFtp();
        CamelContext ctx = new DefaultCamelContext();

        try {
            ctx.addRoutes(routeBuilder);
            ctx.start();
            Thread.sleep(10000);
            ctx.stop();
        }
        catch (Exception e) {
            e.printStackTrace();
        }

    }

ラクダルート:

from("file:./?fileName=Datos.xml&noop=true")
        .split(xpath("//Datos/imagen/text()"))
        .setProperty("rutaArchivo", this.body())
        .log(LoggingLevel.INFO, "imagen: ${body}")
        .process(ExtraerNombre).to("direct:ftp").end(); 

        from("direct:ftp")  
        .pollEnrich("ftp://"+user+"@"+ftp+"/?password="+password+"&recursive=true&passiveMode=true&fileName=${body}&delete="+borrado+"")
        .to("file:C:/outputFolder?flatten=true").end();
    }

streamDownload パラメーターを使用してみましたが、ファイルがダウンロードされません (理由はわかりません)。

.pollEnrich("ftp://"+user+"@"+ftp+"/?password="+password+"&recursive=true&passiveMode=true&streamDownload=true&fileName=${body}&delete="+borrado+"")

コンソール ログ:

情報 | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) が起動しています 0 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) は開始情報 | JMX は有効です 10 [main] INFO org.apache.camel.management.ManagedManagementStrategy - JMX は有効です INFO | ロードされた 185 型コンバーター 208 [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - ロードされた 185 型コンバーター INFO | AllowUseOriginalMessage が有効になっています。元のメッセージにアクセスする必要がない場合は、パフォーマンスが向上する可能性があるため、このオプションをオフにすることをお勧めします。395 [メイン] 情報 org.apache.camel.impl.DefaultCamelContext - AllowUseOriginalMessage が有効になっています。元のメッセージにアクセスする必要がない場合は、パフォーマンスが向上する可能性があるため、このオプションをオフにすることをお勧めします。情報 | StreamCaching は使用されていません。ストリームを使用する場合は、ストリーム キャッシングを有効にすることをお勧めします。詳細はこちら http://camel.apache.org/stream-caching.html 395 [main] INFO org.apache.camel.impl.DefaultCamelContext - StreamCaching は使用されていません。ストリームを使用する場合は、ストリーム キャッシングを有効にすることをお勧めします。詳細については、http://camel.apache.org/stream-caching.htmlを参照してください。 情報 | 395 [main] INFO org.apache.camel.component.file.FileEndpoint - エンドポイントが noop=true で構成されているため、エンドポイントもべき等になるように強制します。キャッシュの最大サイズ: 1000 395 [main] INFO org.apache.camel.component.file.FileEndpoint - デフォルトのメモリ ベースのべき等リポジトリをキャッシュの最大サイズで使用: 1000 INFO | ルート: route1 が開始され、エンドポイント[file://./?fileName=Datos.xml&noop=true] 502 [main] INFO org.apache.camel.impl.DefaultCamelContext - ルート: route1 が開始され、エンドポイント[ file://./?fileName=Datos.xml&noop=true] 情報 | ルート: route2 が開始され、エンドポイント [direct://ftp] 504 [main] INFO org.apache.camel.impl から消費されます。DefaultCamelContext - ルート: route2 が開始され、次から消費されます: Endpoint[direct://ftp] INFO | 合計 2 ルートのうち 2 ルートが開始されます。504 [main] INFO org.apache.camel.impl.DefaultCamelContext - 合計 2 つのルートのうち、2 つが開始されています。情報 | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) は 0.504 秒で開始されました 507 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) ) 0.504 秒で開始しました 情報 | デフォルトの XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533 [Camel (camel-1) スレッド #0 - file://./] INFO org.apache.camel.builder.xml を作成しました。 XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ: route2 が開始され、エンドポイント [direct://ftp] INFO | から消費されました。合計 2 ルートのうち 2 ルートが開始されます。504 [main] INFO org.apache.camel.impl.DefaultCamelContext - 合計 2 つのルートのうち、2 つが開始されています。情報 | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) は 0.504 秒で開始されました 507 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) ) 0.504 秒で開始しました 情報 | デフォルトの XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533 [Camel (camel-1) スレッド #0 - file://./] INFO org.apache.camel.builder.xml を作成しました。 XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ: route2 が開始され、エンドポイント [direct://ftp] INFO | から消費されました。合計 2 ルートのうち 2 ルートが開始されます。504 [main] INFO org.apache.camel.impl.DefaultCamelContext - 合計 2 つのルートのうち、2 つが開始されています。情報 | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) は 0.504 秒で開始されました 507 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) ) 0.504 秒で開始しました 情報 | デフォルトの XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533 [Camel (camel-1) スレッド #0 - file://./] INFO org.apache.camel.builder.xml を作成しました。 XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ: 504 [main] INFO org.apache.camel.impl.DefaultCamelContext - 合計 2 つのルートのうち、2 つが開始されています。情報 | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) は 0.504 秒で開始されました 507 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) ) 0.504 秒で開始しました 情報 | デフォルトの XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533 [Camel (camel-1) スレッド #0 - file://./] INFO org.apache.camel.builder.xml を作成しました。 XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ: 504 [main] INFO org.apache.camel.impl.DefaultCamelContext - 合計 2 つのルートのうち、2 つが開始されています。情報 | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) は 0.504 秒で開始されました 507 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) ) 0.504 秒で開始しました 情報 | デフォルトの XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533 [Camel (camel-1) スレッド #0 - file://./] INFO org.apache.camel.builder.xml を作成しました。 XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ: 504 秒 507 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) が 0.504 秒で開始されました。デフォルトの XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533 [Camel (camel-1) スレッド #0 - file://./] INFO org.apache.camel.builder.xml を作成しました。 XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ: 504 秒 507 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) が 0.504 秒で開始されました。デフォルトの XPathFactory com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f 1533 [Camel (camel-1) スレッド #0 - file://./] INFO org.apache.camel.builder.xml を作成しました。 XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ: XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ: XPathBuilder - デフォルトの XPathFactory を作成しました com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl@5434283f INFO | イメージ:ftp://190.0.56.190:8021/pruebasumman/conductor/71708375.jpg 1635 [Camel (camel-1) スレッド #0 - file://./] INFO route1 - imagen: ftp://190.0.56.190:8021 /プルエバスマン/指揮者/71708375.jpg 情報 | Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1) がシャットダウンしています 10521 [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.15.1.redhat-621084 (CamelContext: camel-1)情報をシャットダウンしています | 2 ルートのグレースフル シャットダウンを開始しています (タイムアウト 300 秒) 10524 [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - 2 ルートのグレースフル シャットダウンを開始しています (タイムアウト 300 秒) INFO | まだ 3 つの処理中および保留中の交換が完了するのを待っています。300 秒でタイムアウトします。10524 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、300 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。299 秒でタイムアウトします。11525 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、299 秒でタイムアウトします。情報 | まだ 3 つの進行中および保留中の交換が完了するのを待っています。298 秒でタイムアウトします。12528 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、298 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。297 秒でタイムアウトします。13529 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの処理中および保留中の交換が完了するのを待っており、297 秒でタイムアウトします。情報 | まだ 3 つの進行中および保留中の交換が完了するのを待っているため、296 秒でタイムアウトします。14540 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、296 秒でタイムアウトします。情報 | まだ 3 つの進行中および保留中の交換が完了するのを待っています。295 秒でタイムアウトします。15555 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、295 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。294 秒でタイムアウトします。16568 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl. DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、294 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。293 秒でタイムアウトします。17569 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、293 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。292 秒でタイムアウトします。18574 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの処理中および保留中の交換が完了するのを待っており、292 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。293 秒でタイムアウトします。17569 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、293 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。292 秒でタイムアウトします。18574 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの処理中および保留中の交換が完了するのを待っており、292 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。293 秒でタイムアウトします。17569 [Camel (camel-1) スレッド #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、293 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。292 秒でタイムアウトします。18574 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの処理中および保留中の交換が完了するのを待っており、292 秒でタイムアウトします。DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、293 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。292 秒でタイムアウトします。18574 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの処理中および保留中の交換が完了するのを待っており、292 秒でタイムアウトします。DefaultShutdownStrategy - まだ 3 つの実行中および保留中の交換が完了するのを待っており、293 秒でタイムアウトします。情報 | まだ 3 つの処理中および保留中の交換が完了するのを待っています。292 秒でタイムアウトします。18574 [Camel (camel-1) thread #2 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - まだ 3 つの処理中および保留中の交換が完了するのを待っており、292 秒でタイムアウトします。

前もって感謝します。

4

1 に答える 1

4

イメージファイルをバイナリモードでダウンロード

デフォルトでは、Camel FTP は ASCII モードでファイルをダウンロードします。

FTPルートに追加binary=trueすると、ASCIIモードからバイナリモードに変わります

于 2018-04-10T03:59:21.857 に答える