File Streaming Doc Polishing

http://stackoverflow.com/questions/40135591/get-string-from-spring-ftp-streaming-inbound-channel-adapter/40136021#40136021

Show an example for removing the remote file after processing.
This commit is contained in:
Gary Russell
2016-10-23 09:53:49 -04:00
committed by Artem Bilan
parent 93d932c095
commit e6c70b5cc6
2 changed files with 37 additions and 2 deletions

View File

@@ -459,6 +459,7 @@ If you do not delete the remote file (e.g. using an outbound gateway with an rm
file being processed again, you can configure an `FtpPersistentFileListFilter` in the `filter` attribute.
If you don't actually want to persist the state, an in-memory `SimpleMetadataStore` can be used with the filter.
If you wish to use a filename pattern (or regex) as well, use a `CompositeFileListFilter`.
The java configuration below shows one technique to remove the remote file after processing.
Use the `max-fetch-size` attribute to limit the number of files fetched on each poll when a fetch is necessary; set to 1 and use a persistent filter when running in a clustered environment;
@@ -490,7 +491,7 @@ public class FtpJavaApplication {
@Bean
@Transformer(inputChannel = "stream", outputChannel = "data")
public org.springframework.integration.transformer.Transformer transformer() {
return new StreamTransformer();
return new StreamTransformer("UTF-8");
}
@Bean
@@ -498,9 +499,26 @@ public class FtpJavaApplication {
return new FtpRemoteFileTemplate(ftpSessionFactory());
}
@ServiceActivator(inputChannel = "data", adviceChain = "after")
@Bean
public MessageHandler handle() {
return System.out::println;
}
@Bean
public ExpressionEvaluatingRequestHandlerAdvice after() {
ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice();
advice.setOnSuccessExpression(
"@template.remove(headers['file_remoteDirectory'] + headers['file_remoteFile'])");
advice.setPropagateEvaluationFailures(true);
return advice;
}
}
----
Notice that, in this example, the message handler downstream of the transformer has an advice that removes the remote file after processing.
[[ftp-outbound]]
=== FTP Outbound Channel Adapter

View File

@@ -568,6 +568,7 @@ If you do not delete the remote file (e.g. using an outbound gateway with an rm
file being processed again, you can configure an `SftpPersistentFileListFilter` in the `filter` attribute.
If you don't actually want to persist the state, an in-memory `SimpleMetadataStore` can be used with the filter.
If you wish to use a filename pattern (or regex) as well, use a `CompositeFileListFilter`.
The java configuration below shows one technique to remove the remote file after processing.
Use the `max-fetch-size` attribute to limit the number of files fetched on each poll when a fetch is necessary; set to 1 and use a persistent filter when running in a clustered environment;
@@ -599,7 +600,7 @@ public class SftpJavaApplication {
@Bean
@Transformer(inputChannel = "stream", outputChannel = "data")
public org.springframework.integration.transformer.Transformer transformer() {
return new StreamTransformer();
return new StreamTransformer("UTF-8");
}
@Bean
@@ -607,9 +608,25 @@ public class SftpJavaApplication {
return new SftpRemoteFileTemplate(sftpSessionFactory());
}
@ServiceActivator(inputChannel = "data", adviceChain = "after")
@Bean
public MessageHandler handle() {
return System.out::println;
}
@Bean
public ExpressionEvaluatingRequestHandlerAdvice after() {
ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice();
advice.setOnSuccessExpression(
"@template.remove(headers['file_remoteDirectory'] + headers['file_remoteFile'])");
advice.setPropagateEvaluationFailures(true);
return advice;
}
}
----
Notice that, in this example, the message handler downstream of the transformer has an advice that removes the remote file after processing.
[[sftp-outbound]]
=== SFTP Outbound Channel Adapter