我在 mule 中有一个流程,可以从大约 470.000 条记录的数据库中获取所有记录。这些记录我必须放入salesforce。Salesforce 只允许我每次迭代插入 200 条记录!不幸的是,我无法在一次数据库调用中获得所有这些记录,它会使机器内存过载。所以我的想法是在 Mule 中使用“foreach”组件来继续循环,直到我从我的 db 调用中获得少于 200 条记录。
这些是如何实现的?
我的配置流程在这里:
<foreach batchSize="200" doc:name="For Each" counterVariableName="foreachCount">
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="select200records" queryTimeout="-1" connector-ref="postgresConnector" doc:name="Database">
<jdbc-ee:query key="select200records" value="select * from parties limit 200 offset #[variable:offset]"/>
</jdbc-ee:outbound-endpoint>
<set-variable variableName="dbPayload" value="#[payload]" doc:name="Variable"/>
<scripting:component doc:name="Script">
<scripting:script engine="jython"><![CDATA[result = len(payload)]]></scripting:script>
</scripting:component>
....