Spring integration 具有get命令的sftp出站网关在同名文件已存在时引发异常

Spring integration 具有get命令的sftp出站网关在同名文件已存在时引发异常,spring-integration,Spring Integration,我试图使用sftp出站网关从远程sftp服务器下载文件。以下是网关配置: <int-sftp:outbound-gateway id="downloadGateway" command="get" command-options="-P" expression="payload.remoteDirectory + payload.filename"

我试图使用sftp出站网关从远程sftp服务器下载文件。以下是网关配置:

<int-sftp:outbound-gateway id="downloadGateway"                 
                command="get" 
                command-options="-P"
                expression="payload.remoteDirectory + payload.filename"
                session-factory="cachingSessionFactory"
                local-directory="downloads"
                auto-create-directory="true"
                use-temporary-file-name="true"
                mode="REPLACE"                  
                local-filename-generator-expression="#remoteFileName + '.' + @currentDate.getDateStr()"
                />

当网关与put命令一起使用时,我是否正确地假设mode属性用于远程文件?对于我来说,有什么方法可以通过sftp出站网关实现我想要的行为吗?

有趣;你的是本周的第二个请求

目前,除了自己删除文件(或将文件提取到临时目录,然后使用文件出站适配器移动它们,提供替换模式)之外,没有其他解决方法

前几天我打开了一个应用程序来添加此功能


实际上,网关上存在的
mode
属性是一个bug,目前已被忽略。

这是一个旧线程,但如果您正在查找mode的有效值,请参见(Ref:):


谢谢你的快速回复。添加允许我得到我想要的!
Caused by: org.springframework.messaging.MessagingException: Local file downloads\myFile.xml.2015-04-14 already exists
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.get(AbstractRemoteFileOutboundGateway.java:700)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway$2.doInSession(AbstractRemoteFileOutboundGateway.java:436)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway$2.doInSession(AbstractRemoteFileOutboundGateway.java:432)
at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:334)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.doGet(AbstractRemoteFileOutboundGateway.java:432)
at org.springframework.integration.file.remote.gateway.AbstractRemoteFileOutboundGateway.handleRequestMessage(AbstractRemoteFileOutboundGateway.java:394)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.handler.MessageHandlerChain$1.send(MessageHandlerChain.java:123)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:95)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:248)
at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:171)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:119)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:105)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.handler.MessageHandlerChain$1.send(MessageHandlerChain.java:123)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:95)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:248)
at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:171)
at org.springframework.integration.splitter.AbstractMessageSplitter.produceOutput(AbstractMessageSplitter.java:129)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:119)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:105)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.handler.MessageHandlerChain$1.send(MessageHandlerChain.java:123)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:95)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:248)
at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:171)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:119)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:105)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:104)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
... 7 more
   /**
     * Append data to any pre-existing files; close after each append.
     */
    APPEND,

    /**
     * Append data to any pre-existing files; do not flush/close after
     * appending.
     * @since 4.3
     */
    APPEND_NO_FLUSH,

    /**
     * Raise an exception in case the file to be written already exists.
     */
    FAIL,

    /**
     * If the file already exists, do nothing.
     */
    IGNORE,

    /**
     * If the file already exists, replace it.
     */
    REPLACE;