49.12. 示例 - 在数据源之间移动数据
常见用例是查询数据,处理数据并将其移动到另一个数据源(ETL 操作)。在以下示例中,我们每小时从源表中检索新的客户记录,过滤/转换它们并将其移到目标表中:
from("timer://MoveNewCustomersEveryHour?period=3600000") .setBody(constant("select * from customer where create_time > (sysdate-1/24)")) .to("jdbc:testdb") .split(body()) .process(new MyCustomerProcessor()) //filter/transform results as needed .setBody(simple("insert into processed_customer values('${body[ID]}','${body[NAME]}')")) .to("jdbc:testdb");