Hi Claus, I've used the policy that you have mentioned below, I do not see the files are moved. Am I missing anything in the following code? Thanks Chandra
CamelContext context = new DefaultCamelContext(); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { public void configure() { CronScheduledRoutePolicy startPolicy = new CronScheduledRoutePolicy(); startPolicy.setRouteStartTime("* 46 12 * * ?"); startPolicy.setRouteStopTime("*/20 * * * * ?"); from("("ftp://172.17.0.150/datatransfer/TEST?username=chandra&password=passwd") .routePolicy(startPolicy).noAutoStartup() .to("file://out"); } }); // start the route and let it do its work context.start(); Thread.sleep(100000); -----Original Message----- From: Claus Ibsen [mailto:claus.ib...@gmail.com] Sent: Thursday, September 20, 2012 4:19 AM To: users@camel.apache.org Subject: Re: Quartz Scheduling to move files Hi See this page http://camel.apache.org/cronscheduledroutepolicy.html You can associate a start and stop time with that policy. On Wed, Sep 19, 2012 at 11:49 PM, Chandra Kalirasa <ckalir...@seatoncorp.com> wrote: > Hi Claus, > Thanks for the response. I am using quartz to scheduling and > SimpleScheduledRoutePolicy stop the route after 2 minutes, but I am able to > move only one file to the out directory though ftp server folder have many > files. Could you please tell that I am missing something from below code? > > Calendar c = Calendar.getInstance(); > > SimpleScheduledRoutePolicy simple = new > SimpleScheduledRoutePolicy(); > c.add(Calendar.MINUTE, 2); > simple.setRouteStopDate(c.getTime()); > > > from("quartz://myFirstTimer?cron=0+36+16+*+*+?") > > .pollEnrich("ftp://172.17.0.150/datatransfer/TEST?username=chandra&password=passwd") > .routePolicy(simple) > .to("file://out"); > > context.start(); > Thread.sleep(10000); > > Thank you, > Chandra > > -----Original Message----- > From: Claus Ibsen [mailto:claus.ib...@gmail.com] > Sent: Wednesday, September 19, 2012 1:33 AM > To: users@camel.apache.org > Subject: Re: Quartz Scheduling to move files > > On Wed, Sep 19, 2012 at 12:17 AM, Chandra Kalirasa > <ckalir...@seatoncorp.com> wrote: >> Hi Claus, >> I went through documents, could not get much info. >> >> This is my scenario: >> I am trying to schedule a job that trigger FTP server to move the files >> another directory. >> >> context.addRoutes(new RouteBuilder() { >> public void configure() { >> from("quartz://myFirstTimer?cron=0+55+16+*+*+?") >> >> .to("ftp://172.17.0.150/datatransfer/TEST?username=chandra&password=passwd") >> .to("file://outputdir"); >> } >> }); >> > > You are a bit wrong here. What you do with from -> to -> to is a > single message is being routed from the quartz toe the ftp endpoint, > and then afterwards to the file endpoint. It uses the pipes and > filters EIP > http://camel.apache.org/pipes-and-filters.html > eg where output from previous becomes input to next. > > In your case the quartz message is an empty message, which causes a > problem when you send it to the ftp endpoint, which would then try to > update the message to the ftp server. And hence why you see the > exception about failing to store the message. > > If you want to download files from ftp server and move them to a file > system, then you need to do a route like > from ftp > to file > > You can then use another route with the quartz endpoint to trigger > when the ftp route should start | stop. Although you can built that > directly into the ftp route using a route policy that supports quartz > scheduling as well. > > There is other alternatives as well. I think we have discussed this in > the past as well. So you may google / search this mailing list and > find some other talks about this. > > And also check this related FAQ > http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html > > >> // start the route and let it do its work >> context.start(); >> Thread.sleep(10000); >> >> I noticed that quartz is scheduling when the time is up, but files are not >> moving and getting the following errors. Please, let me know if there is >> any example using quartz with routing the files. >> >> [ main] StdSchedulerFactory INFO Quartz >> scheduler 'DefaultQuartzScheduler-camel-1' initialized from an externally >> provided properties instance. >> [ main] StdSchedulerFactory INFO Quartz >> scheduler version: 1.8.5 >> [ main] DefaultCamelContext INFO Route: >> route1 started and consuming from: >> Endpoint[quartz://myFirstTimer?cron=0+55+16+*+*+%3F] >> [ main] QuartzComponent INFO >> Starting Quartz scheduler: DefaultQuartzScheduler-camel-1 >> [ main] QuartzScheduler INFO >> Scheduler DefaultQuartzScheduler-camel-1_$_NON_CLUSTERED started. >> [ main] DefaultCamelContext INFO Total >> 1 routes, of which 1 is started. >> [ main] DefaultCamelContext INFO Apache >> Camel 2.10.0 (CamelContext: camel-1) started in 0.752 seconds >> [artzScheduler-camel-1_Worker-1] RemoteFileProducer INFO >> Connected and logged in to: Endpoint[ftp://172.17.0.150/datatransfer/ >> /TEST/backup?password=******&username=chandra] >> [artzScheduler-camel-1_Worker-1] RemoteFileProducer WARN >> Writing file failed with: Cannot store file: >> datatransfer/Delta-HR/ps-drop/TEST/backup/ID-EVG60LT-3-CKALI-58842-1348005273855-0-1 >> [artzScheduler-camel-1_Worker-1] DefaultErrorHandler ERROR Failed >> delivery for (MessageId: ID-EVG60LT-3-CKALI-58842-1348005273855-0-1 on >> ExchangeId: ID-EVG60LT-3-CKALI-58842-1348005273855-0-2). Exhausted after >> delivery attempt: 1 caught: >> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot >> store file: datatransfer/TEST /ID-EVG60LT-3-CKALI-58842-1348005273855-0-1 >> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot >> store file: datatransfer/TEST/ID-EVG60LT-3-CKALI-58842-1348005273855-0-1 >> at >> org.apache.camel.component.file.remote.FtpOperations.doStoreFile(FtpOperations.java:513)[camel-ftp-2.10.0.jar:2.10.0] >> at >> org.apache.camel.component.file.remote.FtpOperations.storeFile(FtpOperations.java:474)[camel-ftp-2.10.0.jar:2.10.0] >> at >> org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:249)[camel-core-2.10.0.jar:2.10.0] >> >> >> >> >> >> >> >> -----Original Message----- >> From: Claus Ibsen [mailto:claus.ib...@gmail.com] >> Sent: Tuesday, September 18, 2012 10:39 AM >> To: users@camel.apache.org >> Subject: Re: Quartz Scheduling to move files >> >> Hi >> >> See route policy >> http://camel.apache.org/routepolicy >> >> This can be used to schedule routes when they shall be active. >> You can then use this for a route that moves files. >> >> >> On Tue, Sep 18, 2012 at 5:33 PM, Chandra Kalirasa >> <ckalir...@seatoncorp.com> wrote: >>> Hi: >>> >>> I am using Quartz to schedule a job that runs every 20 seconds to move the >>> files from inputdir to outputdir. I am getting errors. Please advise. >>> >>> Thank you, >>> >>> chandra >>> >>> >>> >>> Route: >>> >>> CamelContext context = new DefaultCamelContext(); >>> >>> >>> >>> context.addRoutes(new RouteBuilder() { >>> >>> public void configure() { >>> >>> >>> from("quartz://myTimer?period=2000").to("file://inputdir") >>> >>> .to("file://output"); >>> >>> } >>> >>> }); >>> >>> context.start(); >>> >>> Thread.sleep(10000); >>> >>> context.stop(); >>> >>> >>> >>> >>> >>> Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support >>> persistence. and is not clustered. >>> >>> >>> >>> [ main] StdSchedulerFactory INFO >>> Quartz scheduler 'DefaultQuartzScheduler-camel-1' initialized from an >>> externally provided properties instance. >>> >>> [ main] StdSchedulerFactory INFO >>> Quartz scheduler version: 1.8.5 >>> >>> [ main] DefaultCamelContext INFO >>> Route: route1 started and consuming from: >>> Endpoint[quartz://myTimer?trigger.repeatCount=-1&trigger.repeatInterval=2000] >>> >>> [ main] QuartzComponent INFO >>> Starting Quartz scheduler: DefaultQuartzScheduler-camel-1 >>> >>> [ main] QuartzScheduler INFO >>> Scheduler DefaultQuartzScheduler-camel-1_$_NON_CLUSTERED started. >>> >>> [ main] DefaultCamelContext INFO Total >>> 1 routes, of which 1 is started. >>> >>> [ main] DefaultCamelContext INFO >>> Apache Camel 2.10.0 (CamelContext: camel-1) started in 0.625 seconds >>> >>> [artzScheduler-camel-1_Worker-1] DefaultErrorHandler ERROR >>> Failed delivery for (MessageId: ID-EVG60LT-3-CKALI-52599-1347981629198-0-1 >>> on ExchangeId: ID-EVG60LT-3-CKALI-52599-1347981629198-0-2). Exhausted after >>> delivery attempt: 1 caught: >>> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot >>> store file: inputdir\ID-EVG60LT-3-CKALI-52599-1347981629198-0-1 >>> >>> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot >>> store file: inputdir\ID-EVG60LT-3-CKALI-52599-1347981629198-0-1 >>> >>> at >>> org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:246)[camel-core-2.10.0.jar:2.10.0] >>> >>> at >>> org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:249)[camel-core-2.10.0.jar:2.10.0] >>> >>> at >>> org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:151)[camel-core-2.10.0.jar:2.10.0] >>> >>> at >>> org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:76)[camel-core-2.10.0.jar:2.10.0] >>> >>> at >>> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[camel-core-2.10.0.jar:2.10.0] >>> >>> at >>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)[camel-core-2.10.0.jar:2.10.0] >>> >>> at >>> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:120)[camel-core-2.10.0.jar:2.10.0] >>> >>> at >>> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:292)[camel-core-2.10.0.jar:2.10.0] >>> >>> at o >>> >>> >>> >>> >>> >>> >>> >> >> >> >> -- >> Claus Ibsen >> ----------------- >> FuseSource >> Email: cib...@fusesource.com >> Web: http://fusesource.com >> Twitter: davsclaus, fusenews >> Blog: http://davsclaus.com >> Author of Camel in Action: http://www.manning.com/ibsen >> >> >> > > > > -- > Claus Ibsen > ----------------- > FuseSource > Email: cib...@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen > > > -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen