我是Mule 4的新手,对溪流有以下的理解/怀疑。我真的很感激你的帮助。
例如,我创建了下面的Mule 4应用程序,该应用程序读取具有1毫安记录的CSV文件,并执行以下操作:
的文件。
p('destination.dir') ++ "Output_" ++ vars.counter ++ ".txt"生成100个文件,每个文件包含10k记录。如果选中,每个文件的大小为913 KB。
预期:对于每个记录,将处理n条记录的大小为512 KB的n条记录,并在下一次迭代中实际处理(批大小-n):对于每批处理的10000条记录。是怎么发生的?
骡子流码:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<file:config name="File_Config_1" doc:name="File Config" doc:id="565a1655-beba-4048-942f-ae68887e9b96" />
<file:config name="File_Config" doc:name="File Config" doc:id="5182b61a-dddf-41c1-8d3c-6dbd895b5db7" />
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="f5bdb2ca-dc6f-4b6b-8407-8543bf7522e2" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="dw-streamingFlow">
<http:listener doc:name="Listener" doc:id="78635a2a-959d-41e9-a294-3cc7bb22d36f" config-ref="HTTP_Listener_config" path="/app/fileStream"/>
<file:read path="C:\Users\bbazazx\Documents\TestFolder\InputDirectory\input.csv"
config-ref="File_Config"
outputMimeType="application/csv; streaming=true; header=true" />
<foreach doc:name="For Each" doc:id="eacd49dc-c49f-437a-927e-976add7e57fc" batchSize="500" collection="payload">
<ee:transform doc:name="Transform Message" doc:id="bec02dd1-4c15-47c0-81cf-a7d0bfd64b39">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload map(item,index) -> {
"Country" : item."Country",
"FoodItems" : item."Item Type"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<file:write doc:name="Write" config-ref="File_Config_1" path='#["C:\\Users\\bbazazx\\Documents\\TestFolder\\OutputDirectory\\output" ++ vars.counter ++ ".json"]' />
<logger level="INFO" doc:name="Logger" message="#[payload]" />
</foreach>
</flow>
</mule>发布于 2020-05-31 19:01:35
这取决于每个连接器。Mule 4中的大多数连接器允许流,许多连接器允许配置流策略。详情请参见https://docs.mulesoft.com/mule-runtime/4.3/streaming-about。
可能是DB连接器返回一个封装在流中的数组。骡子将理解它,并以透明的方式处理它。
您可以在调试器中看到有效负载的类是一种流、可迭代或托管游标。这似乎是流媒体的一个迹象。
提到的512 KB是缓冲区的大小。对于存储的可重复流策略,上面的文档链接解释了它:
这种策略最初使用内存中的缓冲区大小为512 KB。对于较大的流,该策略将创建一个临时文件到磁盘以存储内容,而不会溢出内存。
https://stackoverflow.com/questions/62119939
复制相似问题