add a thread.sleep at the end of the main method. or thread.wait

On Thu, Jul 23, 2009 at 1:52 AM, Jon Anstey <[email protected]> wrote:

> I think your main method is terminating before Camel has a chance to do
> anything. org.apache.camel.spring.Main actually starts up a new main thread
> and waits for completion so it doesn't exit right away.
>
> If it fits your usecase, I would recommend just using
> org.apache.camel.spring.Main.
>
> Cheers,
> Jon
>
> On Wed, Jul 22, 2009 at 9:09 AM, arhan <[email protected]> wrote:
>
> >
> > Hi!
> >
> >
> > I have a following code for processing files (see the code below). And
> > there's a difference in the file component behavior depending on how do I
> > start the app.
> >
> >
> > 1) When using the org.apache.camel.spring.Main the application
> initializes
> > and starts to poll the directory with desired periods/delays
> >
> > 2) When starting the application via spring context (the main() method in
> > the code snippet), the application initializes and stops without polling
> > the
> > directory at all.
> >
> >
> >
> > Here's the full code snippet:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <beans xmlns="http://www.springframework.org/schema/beans";
> >      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >      xsi:schemaLocation="
> >      http://www.springframework.org/schema/beans
> > http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
> >      http://camel.apache.org/schema/spring
> > http://camel.apache.org/schema/spring/camel-spring.xsd";>
> >
> >  <camelContext id="importing" xmlns="
> http://camel.apache.org/schema/spring
> > ">
> >   <package>some.project</package>
> >  </camelContext>
> >
> > </beans>
> >
> >
> >
> > package some.project;
> >
> > public class Route  extends SpringRouteBuilder {
> >
> >  public void configure() {
> >   String uri = "file:files" +
> >                     "?initialDelay=15000" +
> >                     "&delay=10000" +
> >                     "&useFixedDelay=true" +
> >
> >
> >
> "&move=backup/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.xml";//backup
> > expression
> >
> >   from(uri).
> >     //some processign done here
> >     .to("log:abrakadabra?level=DEBUG");
> >  }
> >
> >  public static void main(String[] args) {
> >     new ClassPathXmlApplicationContext("tmp-context.xml");
> >  }
> >
> > }
> >
> >
> > ..and here's the log when the app is started via the main() method:
> >
> > 22-07-2009 14:29:59,837 DEBUG DefaultCamelContext - Adding routes from:
> > Routes:
> >
> >
> [Route[[From[file:files?initialDelay=15000&delay=10000&useFixedDelay=true&move=backup/${file:name.noext}-${date:now:yyyyMMddHHmmssSSS}.xml]]
> > -> To[log:abrakadabra?level=DEBUG]]]]]] routes: []
> > ...
> > 22-07-2009 14:29:59,837 DEBUG SpringCamelContext - Starting the
> > CamelContext
> > now that the ApplicationContext has started
> > 22-07-2009 14:29:59,837 INFO  DefaultCamelContext - Apache Camel 2.0-M2
> > (CamelContext:importing) is starting
> > 22-07-2009 14:29:59,837 DEBUG DefaultProducerServicePool - Starting
> service
> > pool: org.apache.camel.impl.defaultproducerservicep...@1df2964
> > ....
> > 22-07-2009 14:30:00,430 DEBUG DefaultProducerServicePool - Stopping
> service
> > pool: org.apache.camel.impl.defaultproducerservicep...@1df2964
> > 22-07-2009 14:30:00,430 INFO  DefaultCamelContext - Apache Camel 2.0-M2
> > (CamelContext:importing) started
> >
> > Process finished with exit code 0
> >
> >
> > And actually the same happens to the timer component, i.e if i just
> change
> > the uri value to something like
> > "timer:cancellationTimer?delay=1000&period=1000"
> >
> >
> >
> > The question is, is this a desired behavior, or it is actually a bug, and
> > the only way to fix this is to use org.apache.camel.spring.Main launcher
> ?
> >
> > Thx,
> > Anton
> > --
> > View this message in context:
> >
> http://www.nabble.com/File-Component-%282.0-M2%29-not-polling-tp24604720p24604720.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
> >
>
>
> --
> Cheers,
> Jon
>
> http://janstey.blogspot.com/
>

Reply via email to