久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 Java DSL 成功進行 ftp 傳輸后移動文件

Move file after successful ftp transfer using Java DSL(使用 Java DSL 成功進行 ftp 傳輸后移動文件)
本文介紹了使用 Java DSL 成功進行 ftp 傳輸后移動文件的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我已經使用 spring-integration java dsl 定義了一個流程來 ftp 傳輸文件,處理它,然后將其傳輸回存檔"目錄,最后將其移動到本地存檔目錄中.這是很容易"的事情:

I've defined a flow using spring-integration java dsl to ftp transfer a file, handle it, then transfer it back in an "archive" dir, and at last move it in a local archive dir. Which is something "quite easy" as:

@Bean
public IntegrationFlow ftpInboundFlow() {
    if (ftpProperties.getEnabled() == false) {
        return null;
    }
    logger.trace("Starting ftp flow");
    return IntegrationFlows
            .from(source -> source.ftp(ftpSessionFactory()).deleteRemoteFiles(true).preserveTimestamp(true)
                    .filter(compositeWithAcceptOnceFilter())                        .remoteDirectory(ftpProperties.getRemoteDirectory())
                    .localDirectory(new File(ftpProperties.getLocalDirectory())).autoCreateLocalDirectory(true),
            consumer -> consumer.id("ftpInboundAdapter")) /* Fine from() */
            .handle(new GenericHandler<File>() {

                @Override
                @Transactional
                public Object handle(File payload, Map<String, Object> headers) {
                    logger.debug("Data arrived {} {}", payload, payload.getClass().getName());
                    return payload;
                }

            }) /* Fine GenericHandler */
            .handleWithAdapter(a -> a.ftp(ftpSessionFactory())
                    .remoteDirectory(ftpProperties.getRemoteArchiveDirectory()).autoCreateDirectory(true))              
            .get();
}

如果我追加

.handleWithAdapter(a -> a.file("'" + ftpProperties.getLocalArchiveDirectory() + "'")
.autoCreateDirectory(true).deleteSourceFiles(true))

在 ftp 適配器配置后,bean 初始化程序回復以下錯誤消息:

after the ftp adapter configuration the bean initializer replies with the following error message:

Caused by: org.springframework.beans.factory.BeanCreationException: The 'currentComponent' (org.springframework.integration.file.remote.handler.FileTransferringMessageHandler@80bfa9d) is a one-way 'MessageHandler' and it isn't appropriate to configure 'outputChannel'. This is the end of the integration flow.

我應該如何解決它?

推薦答案

作為一種解決方法,我重構了我的代碼,放棄了文件適配器:

As a workaround I refactored my code in giving up with the file adapter:

@Bean
public IntegrationFlow ftpInboundFlow() {
    return IntegrationFlows
        .from(source -> source.ftp(ftpSessionFactory()).deleteRemoteFiles(true).preserveTimestamp(true)
                .filter(compositeWithAcceptOnceFilter())                        .remoteDirectory(ftpProperties.getRemoteDirectory())
                .localDirectory(new File(ftpProperties.getLocalDirectory())).autoCreateLocalDirectory(true),
        consumer -> consumer.id("ftpInboundAdapter")) /* Fine from() */
        .handle(new GenericHandler<File>() {

            @Override
            @Transactional
            public Object handle(File payload, Map<String, Object> headers) {
                logger.debug("Data arrived {} {}", payload, payload.getClass().getName());
                /* handle file content here ... */
                /* ... then move it to archive */
                File dstFile = new File("archive", payload);
                FileUtils.moveFile(payload, dstFile);
                return dstFile;
            }

        }) /* Fine GenericHandler */
        /* Archive the remote file */
        .handleWithAdapter(a -> a.ftp(ftpSessionFactory())
                .remoteDirectory(ftpProperties.getRemoteArchiveDirectory()).autoCreateDirectory(true))              
        .get();

}

這篇關于使用 Java DSL 成功進行 ftp 傳輸后移動文件的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 欧美一级大片 | 99久久精品一区二区成人 | 欧美精品一区在线发布 | 日本在线看 | 国产精品亚洲欧美日韩一区在线 | 国产高清视频在线 | 欧美精品福利 | 91精品一区二区三区久久久久久 | 国产偷录视频叫床高潮对白 | 美女黄视频网站 | 亚洲日本乱码在线观看 | 中文字幕在线观看视频网站 | 毛片一区二区三区 | 在线观看中文字幕av | 性做久久久久久免费观看欧美 | 国产亚洲精品久久久久动 | 黄色在线免费观看视频网站 | 日韩视频精品在线 | 久久精品国产一区二区三区不卡 | 特黄色一级毛片 | 在线观看亚| 日韩欧美国产精品综合嫩v 一区中文字幕 | 亚洲精品18| 久热久热 | 一区二区三区日本 | 精品一二 | 免费在线观看一区二区三区 | www国产亚洲精品久久网站 | 久久精品久久久久久 | 国产a视频| 日日操夜夜摸 | 在线免费观看黄色网址 | 国产98色在线 | 日韩 | 免费看色| 断背山在线观看 | 一级做a爰片性色毛片 | 91不卡| 欧美日韩在线免费观看 | 老头搡老女人毛片视频在线看 | 亚洲国产成人精品久久久国产成人一区 | 久久成人国产 |