I'm trying to copy a csv
file to a local directory and then parse the SftpInputStream
. The file is copied correctly. However, although I set streaming
to false
in the file connector, it seems as the file inbound-endpoint
closes the stream so that my transformer cannot parse the stream.
How can I prevent the file:outbound-endpoint
from closing the stream
after it has copied the file?
These are my connectors:
<sftp:connector name="mySftpConnector" pollingFrequency="1000" autoDelete="true" />
<file:connector name="myFileOutputConnector" streaming="false" outputPattern="#[header:originalFilename]" />
This is my flow:
<flow name="myFlow" processingStrategy="synchronous">
<sftp:inbound-endpoint
address="xxx"
connector-ref="mySftpConnector" autoDelete="false">
<file:filename-wildcard-filter pattern="*.csv"/>
</sftp:inbound-endpoint>
<file:outbound-endpoint path="/archive" connector-ref="myFileOutputConnector" />
<transformer ref="mySftpTransformer" />
<component>
<spring-object bean="mySftpHandler" />
</component>
</flow>
The exception thrown is:
java.io.IOException: Stream closed
at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:145)
at java.io.BufferedInputStream.read(BufferedInputStream.java:308)
at org.mule.transport.sftp.SftpInputStream.read(SftpInputStream.java:90)
...
If streaming
is not enabled on the FTP
connector, Mule
will attempt to read a file it picks up from the FTP server into a byte[] to be used as the payload of the MuleMessage. And stream is closed after that.
If streaming
is used on inbound endpoints
it is the responsability of the user to close the input stream. You can turn on the stream
and try