我对Apache Camel非常非常新,我希望创建一个简单的应用程序,从mysql db 1中读取200个产品,然后将产品插入到mysql db 2中。数据不需要更改,它只是一个批量选择,然后批量插入。
我一直在查看使用sql组件的camel-sql-example项目。我喜欢它的结构方式,所以我试图将这个示例项目作为我的基础。
是否有人能够帮助我找到一个好的例子的位置,或者给我一个粗略的指示我的骆驼路线(春天arcehtype)应该是什么样的?
这样的事情是否正确?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="sourceDataSource" class="org.apache.commons.dbcp.BasicDataSource">
...
</bean>
<bean id="targetDataSource" class="org.apache.commons.dbcp.BasicDataSource">
...
</bean>
<!-- configure the Camel SQL component to use the JDBC data source -->
<bean id="sourceSql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="sourceDataSource"/>
</bean>
<bean id="targetSql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="targetDataSource"/>
</bean>
<bean id="productBean" class="org.apache.camel.example.sql.ProductBean"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder location="classpath:sql.properties" id="placeholder"/>
<route id="processProduct-route">
<from uri="sourceSql:{{sql.selectProduct}}"/>
<to uri="targetSql:{{sql.insertProduct}}"/>
<log message="${body}"/>
</route>
</camelContext>
谢谢
答案 0 :(得分:0)
我今天测试了这个,我上面指出的似乎工作!我没想到的是,路线只是循环并继续多次运行。我只需要它运行一次。我正在研究如何实现这一目标。