When you create a route, it already creates a consumer for your endpoint.
What you need to do is, instead of defining a route, use the ConsumerTemplate to invoke the endpoint programmatically and receive the response.
public class MySFTPInvoker {
private CamelContext camelContext;
public String invoke() {
ConsumerTemplate consumer = camelContext.createConsumerTemplate();
String out = consumer.receiveBody(
"sftp://{{ftp.server.host}}:{{ftp.server.port}}/{{ftp.root.dir}}?
username={{user}}&password={{password}}", 5000,
String.class); //5000 is the receive timeout
return out;
}
}
If you are using Spring Boot, you could simply autowire the CamelContext in to your bean.
https://camel.apache.org/manual/consumertemplate.html
Here are some test cases from the Apache Camel source,
https://github.com/apache/camel/blob/main/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/integration/SftpConsumeTemplateIT.java