You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Aman Chandna <ac...@progress.com> on 2009/06/17 10:04:52 UTC

Camel Timer Componenet

Hi I  have following issuses while working with timer component.

1. How to set the  time as a part of the URI, i have come  across the
examples where periord and fixedrate  are set as a part of the URI  like the
following  URI 
from("timer://foo?fixedRate=true&period=60000").to("bean:myBean?method=someMethodName");

if i have to set the time , how will i set it as a part of the URI?

2. I have the camel route following 

/////////////////////Camel route file starts //////////////////////////////
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring-1.5.0.xsd">
	<import resource="test.xml" />
	<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
		id="camelroute">
		<route id="null_1">
			<description />
			<from id="Timer_0"
			
uri="timer://myfirsttimer?period=10000&amp;delay=0&amp;fixedRate=true&amp;daemon=true">
				<description>Timer: The timer component is used to generate message
exchanges when a timer fires</description>
			</from>
			<to id="Generic_0" uri="bean:myClass?method=invoke">
				<description>Generic: Specifies a general endpoint URL</description>
			</to>
		</route>
	</camelContext>
</beans>
////////////////////Camel Route file ends
/////////////////////////////////////////////////////////////////////

I was expecting it will call the invoke method of bean named myClass every
10 seconds, but it is called 
only once as indicated by the following console
////////////console starts ////////////

Listening for transport dt_socket at address: 8708
current Working directory is C:\EclipseWS\runtime-New_configuration\test
##### class com.fusesource.tools.eip.run.debugger.scaffolded.CamelLauncher
PARAMS => debug=false, run=true, debugPort=1835, eventPort=1836,
contextFileName=D:/Installs/IONA/Eclipse3.4.1/eclipse/runtime-New_configuration(1)/FuseOne/src/main/resources/META-INF/spring/wiretap-camel.xml
#####
##### debug=false, debugPort=1835, eventPort=1836,
contextFileName=file:/C:/EclipseWS/runtime-New_configuration/test/default-camel.xml
#####
log4j:WARN No appenders could be found for logger
(org.springframework.context.support.FileSystemXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
invoked

////////////console ends /////////////


//////////////////bean -myclass starts ///////////////
public class MyClass {

	public void invoke() {

		System.out.println("invoked");

	}
}
//////////////////bean -myclass ends///////////////

So why is it the invoke method of the bean myClass called only once?

if somebody has the answers to above questions,please do revert back.

Regards,
Aman.
-- 
View this message in context: http://www.nabble.com/Camel-Timer-Componenet-tp24068841p24068841.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel Timer Componenet

Posted by Ashwin Karpe <as...@progress.com>.
Hi Aman,

Looks like the Timer component may not be right for you if the intervals you
are looking at span days. Obviously you can calculate the period in
milliseconds and exrapolate that value to days, however, if you are looking
for a scheduler then you should use the quartz component in camel

http://camel.apache.org/quartz.html http://camel.apache.org/quartz.html 

Hope this helps.

Cheers,

Ashwin...


Aman Chandna wrote:
> 
> Hi I  have following issuses while working with timer component.
> 
> 1. How to set the  time as a part of the URI, i have come  across the
> examples where periord and fixedrate  are set as a part of the URI  like
> the following  URI 
> from("timer://foo?fixedRate=true&period=60000").to("bean:myBean?method=someMethodName");
> 
> if i have to set the time , how will i set it as a part of the URI?
> 
> 2. I have the camel route following 
> 
> /////////////////////Camel route file starts
> //////////////////////////////
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <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://activemq.apache.org/camel/schema/spring
> http://activemq.apache.org/camel/schema/spring/camel-spring-1.5.0.xsd">
> 	<import resource="test.xml" />
> 	<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
> 		id="camelroute">
> 		<route id="null_1">
> 			<description />
> 			<from id="Timer_0"
> 			
> uri="timer://myfirsttimer?period=10000&amp;delay=0&amp;fixedRate=true&amp;daemon=true">
> 				<description>Timer: The timer component is used to generate message
> exchanges when a timer fires</description>
> 			</from>
> 			<to id="Generic_0" uri="bean:myClass?method=invoke">
> 				<description>Generic: Specifies a general endpoint URL</description>
> 			</to>
> 		</route>
> 	</camelContext>
> </beans>
> ////////////////////Camel Route file ends
> /////////////////////////////////////////////////////////////////////
> 
> I was expecting it will call the invoke method of bean named myClass every
> 10 seconds, but it is called 
> only once as indicated by the following console
> ////////////console starts ////////////
> 
> Listening for transport dt_socket at address: 8708
> current Working directory is C:\EclipseWS\runtime-New_configuration\test
> ##### class com.fusesource.tools.eip.run.debugger.scaffolded.CamelLauncher
> PARAMS => debug=false, run=true, debugPort=1835, eventPort=1836,
> contextFileName=D:/Installs/IONA/Eclipse3.4.1/eclipse/runtime-New_configuration(1)/FuseOne/src/main/resources/META-INF/spring/wiretap-camel.xml
> #####
> ##### debug=false, debugPort=1835, eventPort=1836,
> contextFileName=file:/C:/EclipseWS/runtime-New_configuration/test/default-camel.xml
> #####
> log4j:WARN No appenders could be found for logger
> (org.springframework.context.support.FileSystemXmlApplicationContext).
> log4j:WARN Please initialize the log4j system properly.
> invoked
> 
> ////////////console ends /////////////
> 
> 
> //////////////////bean -myclass starts ///////////////
> public class MyClass {
> 
> 	public void invoke() {
> 
> 		System.out.println("invoked");
> 
> 	}
> }
> //////////////////bean -myclass ends///////////////
> 
> So why is it the invoke method of the bean myClass called only once?
> 
> if somebody has the answers to above questions,please do revert back.
> 
> Regards,
> Aman.
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://www.nabble.com/Camel-Timer-Componenet-tp24068841p24074201.html
Sent from the Camel - Users mailing list archive at Nabble.com.