copy database records and insert them in another database

View: New views
6 Messages — Rating Filter:   Alert me  

copy database records and insert them in another database

by linuca :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Everybody!

Evey 15 min, I need to copy all the the created records in a database table, send them through ActiveMQ to another system, and then insert them in another database table. I asked in the ActiveMQ forum, and they suggested I used Camel to achieve this.

I've read the documentation, and I still don't have a clue on how to do this, I'm not even sure how to start .

Can anyone help me please?

Thanks in advance.


Re: copy database records and insert them in another database

by Stan Lewis-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Welcome!

camel-ibatis might be a good place to start -
http://camel.apache.org/ibatis.html
There's even an example that uses a timer to poll from a database and send
the result set to an activemq queue...

Also, did you read the getting started guide -
http://camel.apache.org/getting-started.html

On Wed, Oct 14, 2009 at 9:09 AM, linuca <linuca@...> wrote:

>
> Hi Everybody!
>
> Evey 15 min, I need to copy all the the created records in a database
> table,
> send them through ActiveMQ to another system, and then insert them in
> another database table. I asked in the ActiveMQ forum, and they suggested I
> used Camel to achieve this.
>
> I've read the documentation, and I still don't have a clue on how to do
> this, I'm not even sure how to start :-(.
>
> Can anyone help me please?
>
> Thanks in advance.
>
>
> --
> View this message in context:
> http://www.nabble.com/copy-database-records-and-insert-them-in-another-database-tp25890733p25890733.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>

Re: copy database records and insert them in another database

by linuca :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Stan! Thank you! You let a blind woman see...

Right now I'm reading the pdf Camel manual. I guess this is the best starting point.

One thing I've seen frequently in the code (but I haven't found a comprehensible explanation in the documentation), is the use of "mock:something". For example:

<code>
from("direct:start")
    .to("ibatis:selectAllAccounts?statementType=QueryForList")
    .to("mock:result");
</code>

What is "mock:result"? Is that the List where the result is mapped? For example, if I have a table named clients and a mapping bean named ClientBean.java, should I create a new List<ClientBean> first?


Stan Lewis-3 wrote:
Welcome!

camel-ibatis might be a good place to start -
http://camel.apache.org/ibatis.html
There's even an example that uses a timer to poll from a database and send
the result set to an activemq queue...

Also, did you read the getting started guide -
http://camel.apache.org/getting-started.html

On Wed, Oct 14, 2009 at 9:09 AM, linuca <linuca@mailinator.com> wrote:

>
> Hi Everybody!
>
> Evey 15 min, I need to copy all the the created records in a database
> table,
> send them through ActiveMQ to another system, and then insert them in
> another database table. I asked in the ActiveMQ forum, and they suggested I
> used Camel to achieve this.
>
> I've read the documentation, and I still don't have a clue on how to do
> this, I'm not even sure how to start :-(.
>
> Can anyone help me please?
>
> Thanks in advance.
>
>
> --
> View this message in context:
> http://www.nabble.com/copy-database-records-and-insert-them-in-another-database-tp25890733p25890733.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>

Re: copy database records and insert them in another database

by James.Strachan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/10/14 linuca <linuca@...>:
>
> Hello Stan! Thank you! You let a blind woman see...
>
> Right now I'm reading the pdf Camel manual. I guess this is the best
> starting point.
>
> One thing I've seen frequently in the code (but I haven't found a
> comprehensible explanation in the documentation), is the use of
> "mock:something".

Camel uses URIs to refer to endpoints...
http://camel.apache.org/uris.html

the word before the ':' character refers to the type of endpoint -
they are all shown on that link above. To save you searching, here's
what mock: means...

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

--
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: copy database records and insert them in another database

by Stan Lewis-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No the "mock" endpoint is only used for testing.  You see it in a lot of
examples because the examples are typically taken from unit tests from
Camel.  More info on "mock" is here - http://camel.apache.org/mock.html
To be honest a good way to get a handle on  a particular component is to
start by looking at the tests for that component, for example here's the
ibatis tests -
https://svn.apache.org/repos/asf/camel/trunk/components/camel-ibatis/src/test/java/org/apache/camel/component/ibatis/

An interesting one you might want to check out is
IBatisQueryForListWithSplitTest.java, this route gets a couple records from
the DB and splits the map up into separate elements.  In your case instead
of mock you'd probably be using camel's activemq endpoint instead -
http://camel.apache.org/activemq.html

Hope that helps!

On Wed, Oct 14, 2009 at 10:58 AM, linuca <linuca@...> wrote:

>
> Hello Stan! Thank you! You let a blind woman see...
>
> Right now I'm reading the pdf Camel manual. I guess this is the best
> starting point.
>
> One thing I've seen frequently in the code (but I haven't found a
> comprehensible explanation in the documentation), is the use of
> "mock:something". For example:
>
> <code>
> from("direct:start")
>    .to("ibatis:selectAllAccounts?statementType=QueryForList")
>    .to("mock:result");
> </code>
>
> What is "mock:result"? Is that the List where the result is mapped? For
> example, if I have a table named clients and a mapping bean named
> ClientBean.java, should I create a new List<ClientBean> first?
>
>
>
> Stan Lewis-3 wrote:
> >
> > Welcome!
> >
> > camel-ibatis might be a good place to start -
> > http://camel.apache.org/ibatis.html
> > There's even an example that uses a timer to poll from a database and
> send
> > the result set to an activemq queue...
> >
> > Also, did you read the getting started guide -
> > http://camel.apache.org/getting-started.html
> >
> > On Wed, Oct 14, 2009 at 9:09 AM, linuca <linuca@...> wrote:
> >
> >>
> >> Hi Everybody!
> >>
> >> Evey 15 min, I need to copy all the the created records in a database
> >> table,
> >> send them through ActiveMQ to another system, and then insert them in
> >> another database table. I asked in the ActiveMQ forum, and they
> suggested
> >> I
> >> used Camel to achieve this.
> >>
> >> I've read the documentation, and I still don't have a clue on how to do
> >> this, I'm not even sure how to start :-(.
> >>
> >> Can anyone help me please?
> >>
> >> Thanks in advance.
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/copy-database-records-and-insert-them-in-another-database-tp25890733p25890733.html
> >> Sent from the Camel - Users (activemq) mailing list archive at
> >> Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/copy-database-records-and-insert-them-in-another-database-tp25890733p25892765.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>

Re: copy database records and insert them in another database

by linuca :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I read about iBatis and tested some examples. But I think it is too complex for what I try to achieve.

Now I just send an SQL query as a message from a Master class to a Slave class (in a different host). The latter executes it and stores the records in a List, and then sends the List back with the result.

Thanks for the help.