How about using the quartz to call a processor? In this processor we can
start the route of the FTP endpoint, and we may consider to use other
quartz endpoint to stop the route.
from(quartz://scheduledpoll?cron=0/20+*+*+*+*+?").processor(new
Processor() {
void process(Exchange exchange) throws Exception {
CamelContext context = exchange.getCamelContext();
context.startRoute("ftpRoute");
// you can also stop the route here
// context.stopRoute("ftpRoute");
}
}
from("ftp://sc...@localhost/public/reports?password=tiger&binary=true).routeId("ftpRoute").to
...;
Willem
leNerd wrote:
That doesn't quite make it, unfortunately. I did see the example you
mentioned prior to posting. It does not poll according to a schedule - e.g.
every day at 1 o'clock - but according to a timer with a given delay.
leNerd
Ashwin Karpe wrote:
Hi,
This capability is already available in the FTP component. You do not need
to do pollEnrich etc.
Please check out the sample available in the link
http://camel.apache.org/ftp.html http://camel.apache.org/ftp.html
The sample is given below.
Cheers,
Ashwin...
----------------------------------------------------------------------------------
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
// we use a delay of 60 minutes (eg. once pr. hour we poll the
FTP server
long delay = 60 * 60 * 1000L;
// from the given FTP server we poll (= download) all the
files
// from the public/reports folder as BINARY types and store
this as files
// in a local directory. Camel will use the filenames from the
FTPServer
// notice that the FTPConsumer properties must be prefixed
with "consumer." in the URL
// the delay parameter is from the FileConsumer component so
we should use consumer.delay as
// the URI parameter name. The FTP Component is an extension
of the File Component.
from("ftp://sc...@localhost/public/reports?password=tiger&binary=true&consumer.delay="
+ delay).
to("file://target/test-reports");
}
};
}
----------------------------------------------------------------------------
leNerd wrote:
Hi!
I want to start a route using a quartz component with a cron statement.
Then use pollEnrich to obtain messages from an FTP server and forward
them via a route. Something along these lines (Java DSL):
from("quartz://scheduledpoll?cron=0/20+*+*+*+*+?")
.pollEnrich("ftp://" + props.getProperty("ftp.server") +
props.getProperty("ftp.inbox")
+ "?username=" + props.getProperty("ftp.user")
+ "&password=" +
props.getProperty("ftp.password")
+ "&move=done")
.to("direct:someChannel");
The problem is then, that as the quartz endpoint issues its one message
per firing, the pollEnrich component only retrieves one (that is 1) file
from the FTP server, as opposed to the intended batch of all available
files!
The above is only an attempt to check a FTP server once in a while and
then retrieve all available files. I'm open to other solutions - also
using Spring XML DSL.
Reg. leNerd