I am looking for an way to pass InputStream to service class method by using service-activator, with below configuration tested and seems the service-activator was not called. can any point where am doing wrong?
<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"/>
where in service class an method with InputStream parameter created :
@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();
}
}
Remove the chain - the <file:splitter/>
reads the file from the inputStream and emits each line as a Message<String>
.
Since you want to consume the inputStream yourself, you don't want that. Your service method is then correct.
Simply change the reply-channel to outboundGetStream
and change the service activator's input channel to that.