0

我正在寻找一种通过使用服务激活器将 InputStream 传递给服务类方法的方法,并测试了以下配置,并且似乎没有调用服务激活器。有什么地方做错了吗?

<bean id="sftpSessionFactory" ... />

<int:channel id="inboundGetStream">
    <int:queue />
</int:channel>

<int-sftp:outbound-gateway session-factory="sftpSessionFactory"
              request-channel="inboundGetStream"
              command="get"
              command-options="-stream"
              expression="payload"
              remote-directory="ftpTarget"
              reply-channel="streamHandler" />

<int:service-activator input-channel="inboundGetStream" ref="streamHandler" method="handleMessage"/>

在服务类中,创建了具有 InputStream 参数的方法:

@Service("streamHandler")
public class StreamHandler {

    public void handleMessage(InputStream file, @Headers['file_remoteSession']DefaultSftpSessionFactory session) throws FileNotFoundException, IOException{
        log.debug("############# handleMessage(file) ###########");     
        log.debug(IOUtils.toString(new FileInputStream(file)));
        session.close();
    }
}
4

1 回答 1

1

删除链 -<file:splitter/>从 inputStream 读取文件并将每一行作为Message<String>.

由于您想自己使用 inputStream,因此您不希望这样。那么您的服务方法是正确的。

只需将回复通道outboundGetStream更改为并将服务激活器的输入通道更改为该通道即可。

于 2016-03-13T14:36:31.583 回答