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

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

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

問題描述

我已經(jīng)使用 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 初始化程序回復(fù)以下錯誤消息:

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.

我應(yīng)該如何解決它?

推薦答案

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

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();

}

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

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

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
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 數(shù)據(jù)庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 日本a∨精品中文字幕在线 亚洲91视频 | 欧美视频区| 一级毛片在线播放 | 久久久久久av| 日韩一级免费电影 | 亚洲精品久久久久久久不卡四虎 | 中文在线视频 | 日本特黄特色aaa大片免费 | 国产女人与拘做视频免费 | 在线不卡视频 | 久久久久国产精品一区二区 | 爱草视频| 亚洲欧美中文字幕在线观看 | 精品欧美一区二区三区精品久久 | 超碰人人爱 | 黄色一级特级片 | 欧美激情在线精品一区二区三区 | 天天操天天射综合网 | 中文字幕av第一页 | 国产欧美日韩在线播放 | 草久久 | 亚洲精品电影 | 成人在线免费av | 日韩av免费在线观看 | 亚洲啊v在线 | 欧美久久一区二区三区 | 亚洲久在线 | 久久伊人影院 | 日韩中文在线观看 | 亚洲精品在线免费 | 欧美精品在线一区 | 久久蜜桃资源一区二区老牛 | 秋霞在线一区 | 欧美精品一区二区三区在线播放 | 国产二区在线播放 | 91电影| 亚洲精品亚洲人成人网 | 国产精品自拍视频 | 欧美一级黄视频 | 精品少妇一区二区三区日产乱码 | 91网视频 |