You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by frblondin <th...@gmail.com> on 2011/02/25 23:02:12 UTC

Get updated entries from a DataBase

Hi,

I'm new to Camel. My need is to collect new information from an existing
DataBase. My cursor is quite easy to manage (based on a timestamp) so I need
to regularly check for new entries every minute by doing this query: "Select
* From Table Where DTEVENT > LastManagedEntryDT".

Ideally I'd like to use Spring configuration and the LastManagedEntryDT
value should be stored in a persistent file so that if I restart Camel I
won't grab duplicates events.

Thanks!
-- 
View this message in context: http://camel.465427.n5.nabble.com/Get-updated-entries-from-a-DataBase-tp3400895p3400895.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Get updated entries from a DataBase

Posted by frblondin <th...@gmail.com>.
Nevermind, I used this:


		<route>
			<from uri="timer://foo?fixedRate=true&amp;period=60000"/>
			<to uri="bean:lastRowValue?method=getLastValue"/>
			<to uri="sql:select * from messagesRepo1 Order By
id?dataSourceRef=dataSource1"/>
			<split>
			<simple>body</simple> 
			<to uri="bean:lastRowValue?method=setLastValue"/>
			</split>
		</route>


--
View this message in context: http://camel.465427.n5.nabble.com/Get-updated-entries-from-a-DataBase-tp3400895p4552432.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Get updated entries from a DataBase

Posted by frblondin <th...@gmail.com>.
Thanks, this works!

One last question: how do i split a list in my route? My problem is that the
sql component returns a list and I'like to manage each item within the list.
In my route below the whole query result (list) is sent to my bean instead
of each line individually:

		<route>
			<from uri="timer://foo?fixedRate=true&amp;period=60000"/>
			<to uri="bean:lastRowValue?method=getLastValue"/>
			<to uri="sql:select * from messagesRepo1 Order By
id?dataSourceRef=dataSource1"/>
			<to uri="bean:lastRowValue?method=setLastValue"/>
		</route>

Thanks

--
View this message in context: http://camel.465427.n5.nabble.com/Get-updated-entries-from-a-DataBase-tp3400895p4552420.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Get updated entries from a DataBase

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can code the SQL logic in a java bean, and then use the @Produce
or ProducerTemplate to easily send the message to a Camel route for
further processing.

Then you can use another Camel route with a timer to schedule invoking
your bean at X given interval.




On Fri, Feb 25, 2011 at 11:02 PM, frblondin <th...@gmail.com> wrote:
>
> Hi,
>
> I'm new to Camel. My need is to collect new information from an existing
> DataBase. My cursor is quite easy to manage (based on a timestamp) so I need
> to regularly check for new entries every minute by doing this query: "Select
> * From Table Where DTEVENT > LastManagedEntryDT".
>
> Ideally I'd like to use Spring configuration and the LastManagedEntryDT
> value should be stored in a persistent file so that if I restart Camel I
> won't grab duplicates events.
>
> Thanks!
> --
> View this message in context: http://camel.465427.n5.nabble.com/Get-updated-entries-from-a-DataBase-tp3400895p3400895.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/