我是 Apache Camel 的新手,我一直盯着编写一个应用程序,该应用程序从一个数据库中获取数据并将其插入另一个数据库。我正在使用 sql 组件,并试图弄清楚如何使用 spring dsl 从消息头中获取 CamelSqlUpdateCount、CamelSqlRowCount 和 CamelSqlQuery。
我知道我可以使用这个来获取数据中的属性......
<log message="Processing product ${body[product_id]}"/>
但是当我像这样插入后尝试从标题中获取数据时......
<from uri="sourceSql:{{sql.selectProduct}}"/>
<log message="SELECT,${header.CamelSqlQuery},${header.CamelSqlRowCount}" loggingLevel="INFO" logName="db_log"/>
<to uri="targetSql:{{sql.insertProductOrig}}"/>
<log message="INSERT,CONV_ORIG,${header.CamelSqlQuery},${header.CamelSqlUpdateCount}" loggingLevel="INFO" logName="db_log"/>
它回来是空的。在获得有关在我的路由中打开跟踪以查看消息标头中返回的内容的建议后,我可以看到这些标头属性不存在。我正在连接到 sql server 来选择和 mysql 来插入。有谁知道可能出了什么问题?
我已经从跟踪中附加了一些示例输出......
2013-09-04,21:11:55.615,MacBook-local >>> (processProduct-route) from(sourceSql://SELECT%20TOP%205%20product_id%20FROM%20product_) --> log[SELECT,${header.CamelSqlQuery},${header.CamelSqlRowCount}] <<< Pattern:InOnly, Headers:{breadcrumbId=MacBook-local}, BodyType:org.springframework.util.LinkedCaseInsensitiveMap, Body:{product_id=273}
2013-09-04,21:11:55.625,MacBook-local >>> (processProduct-route) log[SELECT,${header.CamelSqlQuery},${header.CamelSqlRowCount}] --> multicast <<< Pattern:InOnly, Headers:{breadcrumbId=MacBook-local}, BodyType:org.springframework.util.LinkedCaseInsensitiveMap, Body:{product_id=273}
2013-09-04,21:11:55.644,MacBook-local >>> (processProduct-route) from(sourceSql://SELECT%20TOP%205%20product_id%20FROM%20product_) --> targetSql://insert%20into%20conv_stg_product_%20(product_id)%20values%20(:%23product_id) <<< Pattern:InOnly, Headers:{breadcrumbId=MacBook-local}, BodyType:org.springframework.util.LinkedCaseInsensitiveMap, Body:{product_id=273}
2013-09-04,21:11:55.646,MacBook-local >>> (processProduct-route) from(sourceSql://SELECT%20TOP%205%20product_id%20FROM%20product_) --> log[INSERT,CONV_STG,${header.CamelSqlQuery},${header.CamelSqlUpdateCount}] <<< Pattern:InOnly, Headers:{breadcrumbId=MacBook}, BodyType:org.springframework.util.LinkedCaseInsensitiveMap, Body:{product_id=273}
2013-09-04,21:11:55.642,MacBook >>> (processProduct-route) from(sourceSql://SELECT%20TOP%205%20product_id%20FROM%20product_) --> log[INSERT,CONV_ORIG,${header.CamelSqlQuery},${header.CamelSqlUpdateCount}] <<< Pattern:InOnly, Headers:{breadcrumbId=MacBook}, BodyType:org.springframework.util.LinkedCaseInsensitiveMap, Body:{product_id=273}
这是sql语句的样子......
sql.selectProduct=SELECT TOP 5 product_id FROM product_
sql.insertProductOrig=insert into conv_orig_product_ (product_id) values (:#product_id)
这是我的 POM 的摘录,以显示我正在使用的 jdbc 驱动程序...
<!-- SQL Server database driver -->
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.0</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
谢谢