[英]Apache Camel SQL component select all records in a batch mode
我使用 apache camel 作为 ETL,从( select *...
)PostgreSQL 到( insert...
)MariaDB。
PostgreSQL里面有很多条记录(超过1M),想批量处理。
我试过几个标志( batchCount
, batchSize
),但没有一个有效。
我也在 Apache Camel 文档中搜索,但没有成功。
from("sql:SELECT * FROM my_schema.trees?dataSource=#postgersqlDataSource&batch=true")
.convertBodyTo(String.class)
.process(ex -> {
log.info("batch insert for single table");
List<Map<String, Object>> rows = ex.getIn().getBody(List.class);
log.info(String.format("Value: %s", rows.size()));
})
.to("stream:out");
但是程序崩溃了,因为它将所有内容加载到 memory(当然有 1 条记录)。
有什么建议吗?
它运行Spring boot
。
batch
选项仅适用于生产者(例如 to)。 https://camel.apache.org/components/3.20.x/sql-component.html
相反,请查看outputType=StreamList
,您可以在其中将其与拆分 EIP(在流模式下)结合使用来处理行,而无需将所有内容加载到 memory 中。
这也意味着您一次处理 1 行
from sql
split
process (1 row here)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.