Obscur Moirage Obscur Moirage - 4 months ago 75x
Java Question

Spring Integration DSL SFTP good practices

I'm currently trying to push some files using SI DSL SFTP features.

I'm not very fluent using this fwk, so I'm wondering if there's a better way to do what I'm trying to achieve.

It's kind of working like this, except when the files are copied, the rest call falls in a timeout state...

Bonus : Is there some good readings (book or online) about SI DSL ?
(except cafe si sample and reference..)


  • Does this SI flow follows the SI good practices ?

  • Why my rest call is ending with a timeout, although the files are correctly copied to the sftp server ?

Java config :

public class IntegrationConfig {

//flow gateway
public interface FlowGateway {
@Gateway(requestChannel = "SftpFlow.input")
Collection<String> flow(Collection<File> name);


//sftp flow bean
public IntegrationFlow SftpFlow() {
return f -> f
.handle(Sftp.outboundAdapter(this.sftpSessionFactory(), FileExistsMode.REPLACE)

//sftp session config
public DefaultSftpSessionFactory sftpSessionFactory() {
System.out.println("Create session");
DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
return factory;


A RestController class :

private FlowGateway flowGateway;

public String testSftp() {
flowGateway.flow(Arrays.asList(file1, file2, file3);

  1. Spring Integration Java DSL is fully based on the Spring Integration Core. So, all concepts, recipes, docs, samples etc. are applied here as well.

  2. What is the question though? Let me guess: "why does it timeout and blocks?" That is obvious for me because I know where to read, but that might not be clear for others. Please, be more specific the next time: there are enough guys on SO who can close your question as "Unclear".

So, let's analyze what you have and why it isn't as you'd like.

Endpoints in Spring Integration can be one-way (Sftp.outboundAdapter()) or request-reply (Sftp.outboundGateway()). It's not surprise when it is one-way there is nothing to return and continue the flow or send reply, like in your case.

I'm sure you are not interested in the reply, otherwise you have used a different endpoint.

The process stops exactly after sending all the item from .split() and there is nothing to send back to the @Gateway as your code implies:

Collection<String> flow(Collection<File> name);

Having a non-void return type requires a reply from the downstream flow on the requestChannel.

See Messaging Gateway for more information.

Also consider to use

.channel(c -> c.executor(taskExecutor()))

after .split() to send your files to SFTP in parallel.

P.S. I'm not sure what you need to read else because so far everything is fine in your code, just only this nasty reply issue.