You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by KatoneVi <ka...@gmail.com> on 2015/11/19 20:54:13 UTC

Camel fetch multiple data from database once, then stops?

Hello everyone,

I used the search on this site to look for similar problems but failed to
find it.  Perhaps it is because I am asking it incorrectly?

So currently, I have camel fetching data from my database... and then
outputting it onto a text file.  The table only has 3 rows, so it should end
rather fast.  Is it possible to stop this "loop" after it complete looping
through the database table?  This is what I am doing at the moment:

from("sqlComponent:{{sql.selectNewTopic}}")
			.bean(new SqlDataConverter(), "transformContent")
			.log("${body}")
		
.to("file:C:/Users/myname/Desktop/eclipse/workspace/CamelExample/resource/output");

Any suggestions and guidance would be truly appreciated!



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-fetch-multiple-data-from-database-once-then-stops-tp5774117.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel fetch multiple data from database once, then stops?

Posted by KatoneVi <ka...@gmail.com>.
I should add that instead of creating just three files for those three
rows... it creates 18 files... the other 15 being duplicates of the first 3.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-fetch-multiple-data-from-database-once-then-stops-tp5774117p5774118.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel fetch multiple data from database once, then stops?

Posted by KatoneVi <ka...@gmail.com>.
Solved it!  Thanks to Claus's suggestion from this post

http://camel.465427.n5.nabble.com/Stop-a-SQL-route-in-Apache-Camel-td5768252.html

I changed the structure to this!

from("timer:foo?period=5s")
			.to("sqlComponent:{{sql.selectNewTopic}}")
			.bean(new SqlDataConverter(), "transformContent")
		
.to("file:C:/Users/myname/Desktop/eclipse/workspace/CamelExample/resource/output");

Instead of using FROM  for the sqlComponent, I used TO()  instead.  From is
now my timer, which sets how often it loops (period of 5 second on this
example).  Thanks guys!



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-fetch-multiple-data-from-database-once-then-stops-tp5774117p5774121.html
Sent from the Camel - Users mailing list archive at Nabble.com.