I have a requirement of generating a file from webservice and FTP to a location.
Route1:
from("direct:start")
.routeId("generateFileRoute")
.setHeader(Exchange.HTTP_METHOD, constant("GET"))
.setHeader(Exchange.HTTP_URI, simple(URL))
.setHeader("Authorization", simple(APP_KEY))
.to(URL)
.unmarshal(listJacksonDataFormat)
.marshal(bindyCsvDataFormat)
.to(fileDirLoc + "?fileName=RMA_OUT_${date:now:MMddyyyy_HHmmss}.csv&noop=true");
Route 2: FTP Route
from("file://"+header("CamelFileNameProduced"))
.routeId("ftpRoute")
.to("sftp://FTP_HOST/DIR?username=???&password=???)
To start the route
Exchange exchange = template.request("direct:start", null);
Object filePathObj = exchange.getIn().getHeader("CamelFileNameProduced");
if (filePathObj != null) { // Makesure Route1 has created the file
camelContext.startRoute("ftpRoute"); // Start FTP route
template.send(exchange); // Send exchange from Route1 to Route2
}
The above code worked when I hard-coded the location in FTP route. Can someone please help, how can I pipeline these 2 routes and pass output of Route 1 ("File Name") to Route2 for FTP?