It looks like in the sample code which starts camel context, you are also stopping the context.
If you want timer to run continuously, your context should always be up and running as well. Can you also add a very long sleep command just to ensure that and test the same ? -Ravi ________________________________________ From: mikes300 [[email protected]] Sent: Thursday, July 24, 2014 11:30 PM To: [email protected] Subject: RE: Camel Java routes using Timer firing only once *Hi Ravi,* I tried, but same results. Runs once but not again. Here are the log entries for it. I even tried omitting the context.stop, no success... 7:32:12,460 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) Apache Camel 2.13.1 (CamelContext: camel-1) is starting 07:32:12,461 INFO [org.apache.camel.management.ManagedManagementStrategy] (default task-4) JMX is enabled 07:32:12,473 WARN [org.apache.camel.management.DefaultManagementLifecycleStrategy] (default task-4) This CamelContext(camel-1) will be registered using the name: camel-1-1 due to clash with an existing name already registered in MBeanServer. 07:32:12,590 INFO [org.apache.camel.impl.converter.DefaultTypeConverter] (default task-4) Loaded 191 type converters 07:32:12,742 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. 07:32:12,743 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html 07:32:12,802 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) Route: route1 started and consuming from: Endpoint[timer://foo?fixedRate=true&period=1000] 07:32:12,808 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) Total 1 routes, of which 1 is started. 07:32:12,809 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) Apache Camel 2.13.1 (CamelContext: camel-1) started in 0.349 seconds 07:32:13,811 INFO [stdout] (default task-4) 07:32:13.810 [default task-4] DEBUG com.sial.integration.test.TestRoute - sync route try block 2 07:32:13,811 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) Apache Camel 2.13.1 (CamelContext: camel-1) is shutting down 07:32:13,812 INFO [org.apache.camel.impl.DefaultShutdownStrategy] (default task-4) Starting to graceful shutdown 1 routes (timeout 300 seconds) 07:32:13,827 INFO [org.apache.camel.impl.DefaultShutdownStrategy] (Camel (camel-1) thread #1 - ShutdownTask) Waiting as there are still 1 inflight and pending exchanges to complete, timeout in 300 seconds. 07:32:14,830 INFO [org.apache.camel.impl.DefaultShutdownStrategy] (Camel (camel-1) thread #1 - ShutdownTask) Route: route1 shutdown complete, was consuming from: Endpoint[timer://foo?fixedRate=true&period=1000] 07:32:14,831 INFO [org.apache.camel.impl.DefaultShutdownStrategy] (default task-4) Graceful shutdown of 1 routes completed in 1 seconds 07:32:14,838 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) Apache Camel 2.13.1 (CamelContext: camel-1) uptime 2.379 seconds 07:32:14,839 INFO [org.apache.camel.impl.DefaultCamelContext] (default task-4) Apache Camel 2.13.1 (CamelContext: camel-1) is shutdown in 1.027 seconds * If it matters, I am calling the route from a bean injected into a REST call. See below.* package com.sial.integration.test; import javax.inject.Inject; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import org.apache.logging.log4j.Logger; @Path("/TestRouteInvoker/Start") public class TestRouteInvoker{ /** The logger. */ @Inject Logger logger; * @Inject TestRoute TestRoute;* @GET @Produces("text/plain") public String putMessage() { logger.debug("/TestRouteInvoker/Start ok"); *TestRoute.createRoute();* return "/TestRouteInvoker/Start ok"; } } *And then the route class:* package com.sial.integration.test; import org.apache.camel.CamelContext; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.DefaultCamelContext; import org.apache.logging.log4j.Logger; import java.util.*; import javax.inject.Inject; public class TestRoute { /** The logger. */ @Inject Logger logger; public void createRoute() { CamelContext context = new DefaultCamelContext(); logger.debug("I am in the SYNC route"); try { logger.debug("sync route try block 1"); context.addRoutes(new RouteBuilder() { public void configure() { *// from("timer://foo?fixedRate=true&period=1000").setBody(body().append("Time is " + new Date())).to("file:target/reports/?fileName=date.txt"); from("timer://foo?fixedRate=true&period=1000").setBody(constant("Time is " + new Date())).to("file:target/reports/?fileName=date.txt");* } }); context.start(); Thread.sleep(1000); } catch(Exception e){ logger.debug("Exception thrown :" + e); } try { logger.debug("sync route try block 2"); // stop the CamelContext context.stop(); } catch(Exception e){ logger.debug("Exception thrown :" + e); } } } -- View this message in context: http://camel.465427.n5.nabble.com/Camel-Java-routes-using-Timer-firing-only-once-tp5754275p5754408.html Sent from the Camel - Users mailing list archive at Nabble.com. This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient(s), please reply to the sender and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email, and/or any action taken in reliance on the contents of this e-mail is strictly prohibited and may be unlawful. Where permitted by applicable law, this e-mail and other e-mail communications sent to and from Cognizant e-mail addresses may be monitored.
