<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
感谢您的帮助。
答案 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
变体不太有用,因为您需要使用SpelExpressionParser
或LiteralExpression
仅用于简单的dir变体。