user3317519 user3317519 - 11 days ago 6
Java Question

Is it possible to route from HTTPS to SFTP with Apache Camel?

I want to download a CSV file from HTTPS server and send it to SFTP server and I'm using HTTP4 componenet for HTTPS. Is it possible to combine two routes?

{
from("https4:www.00000/00/downloads/sdn.csv?")
.to("sftp://0000000/myhome/?fileName=${file:name}&\");
}

Answer

You need to start with a timer or other "trigger" in order to "get" the file from an http site. By default, 'from uri="http.."' tells Camel to listen on an http port. Also, a Polling Consumer may be helpful.

ref: http://camel.apache.org/timer.html

ref: http://camel.apache.org/polling-consumer.html

Pseudo code:

from("timer:...")
.setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.GET))
.to("https4:www....")  <-- Note: the return is now the ${body} in Camel
.to("sftp://...")