mule 4.4社区版 - 如何解析以流的方式来解析文件数据
我正在使用社区版M子4.4(所以我的理解是 - 无法使用DataWeave(转换) 现在由于CE无法使用“重复的文件存储流”(很好)(在内存流中使用可重复)
现在我的问题是在我在文件中阅读后 - 如何解析内容? 数据全部显示出
org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider
我可以使用DataWeave这很简单:IE
<ee:transform doc:name="Transform Message">
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/json
---
payload map (value,index)->
{
id:value.column_0
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
,但是不使用变换组件(因为我使用了社区版Mule Mule Mul Runtime 4.4),我们如何处理有效负载,这实际上是“流”数据流? 谢谢
请参阅上面的代码,我需要将文件内容(即流)转换为json
edit1: 多亏了@Aled更新以及更多详细信息:以下是我尝试在选项卡划界文件中阅读的文件读取操作。不确定我应该设置输出型号,因此将其设置为“应用程序/CSV”
<file:read doc:name="Read Products file" config-ref="File_Config" outputMimeType='application/csv; header=false; separator=|' path="/employee_master/employees.unl" outputEncoding="utf-8">
<repeatable-in-memory-stream />
</file:read>
I am using Community edition Mule 4.4 ( So my understanding is - cannot use Dataweave ( Transform )
Now due to CE cannot use 'Repetable file store stream' ( which is fine ) ( am using repeatable in memory stream )
Now my problem is after I read in the file - how do I parse the contents ?
The data all shows up as
org.mule.runtime.core.internal.streaming.bytes.ManagedCursorStreamProvider
If I could use Dataweave this was simple enough : i.e.
<ee:transform doc:name="Transform Message">
<ee:message>
<ee:set-payload>
<![CDATA[%dw 2.0
output application/json
---
payload map (value,index)->
{
id:value.column_0
}]]>
</ee:set-payload>
</ee:message>
</ee:transform>
But without using Transform component ( since I am using Community Edition Mule runtime 4.4 ) , how do we handle payload which is really a 'Stream' of data ?
Thanks
Please see above code , I need to convert the file content ( which is a stream ) into JSON
edit1:
Thanks to @aled updating with more details : Below is the file read operation where I am trying to read in a tab delimited file. Was not sure what I should set the outputMimeType so have set it as 'application/csv'
<file:read doc:name="Read Products file" config-ref="File_Config" outputMimeType='application/csv; header=false; separator=|' path="/employee_master/employees.unl" outputEncoding="utf-8">
<repeatable-in-memory-stream />
</file:read>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在以错误的方式思考。首先,您正在查看mule中的实现类,在m子4中,您不应该看。当您尝试处理它时,没有任何文件实际上是“数据流”。是二进制文件吗?不,很明显,如果您使用Map()DataWeave知道如何解析。那么输入文件的数据格式是什么? JSON,CSV,XML等?看来已经设置了正确的格式,因此DataWeave能够解析输入。实际上,您的问题是您要转换数据,但无法在社区版中使用变换组件。同样,在UI中,编辑体验将不好。
您可以在社区版中做的是使用带有表达式的设定付费负载。由于表达式语言仍然是数据宣言,它将完全相同。您将失去转换的图形UI。
You are thinking about it the wrong way. First, you are looking at the implementation class in Mule, which in Mule 4 you should not be looking at. No file is really a 'stream of data' when you are trying to process it. Is it a binary file? No, clearly if you use map() DataWeave knows how to parse it. So what is the data format of the input file? JSON, CSV, XML, etc? It looks like the correct format is already set so DataWeave is able to parse the input. Really your problem is that you want to transform the data but you can not use a Transform component in the community edition. Also the editing experience will not be good in the UI.
What you can do in community edition is use a set-payload with an expression. Since the expression language is still DataWeave it will work exactly the same. You will lose the graphical UI of Transform.