如何在java-spring集成中设置sftp outboud网关中的remotedirectory

时间:2018-01-04 16:24:46

标签: spring-integration spring-integration-sftp

<int-sftp:outbound-gateway id="sftpOutBound"
    session-factory="sftpSessionFactory"   expression="payload" command="put" request-channel="outboundFtpChannel"
    remote-directory="/tmp/tsiftp" reply-channel="sftpReplyChannel"/>

使用上面的xml,我可以发送文件并获得回复。在java中,如何在SftpOutboundGateway中设置远程目录。如果我使用SftpMessageHandler,是否有可能获得回复。评论代码正在传输文件但没有回复。

 @Bean
@ServiceActivator(inputChannel = "outboundFtpChannel")
public MessageHandler transfertoPeopleSoft(){
 /*  SftpMessageHandler handler = new SftpMessageHandler(sftpSessionFactory());
     handler.setRemoteDirectoryExpression(new LiteralExpression("/tmp/tsiftp"));
     return handler;*/
    SftpOutboundGateway sftpOutboundGateway = new  SftpOutboundGateway( sftpSessionFactory(), "put", "/tmp/tsiftp");
    sftpOutboundGateway.setOutputChannelName("sftpReplyChannel");
    return sftpOutboundGateway;
}

 Exception I am getting is
   exception is org.springframework.expression.spel.SpelParseException: Expression [/tmp/tsiftp] @0: EL1070E: Problem parsing left operand

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

SftpOutboundGateway的远程目录可由SftpRemoteFileTemplate及其配置:

/**
 * Set the remote directory expression used to determine the remote directory to which
 * files will be sent.
 * @param remoteDirectoryExpression the remote directory expression.
 */
public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression) {

https://docs.spring.io/spring-integration/docs/5.0.0.RELEASE/reference/html/sftp.html#sftp-rft

随意提出JIRA以改善此事。

我知道Expression变体不太有用,因为您需要使用SpelExpressionParserLiteralExpression仅用于简单的dir变体。