获取xml并在添加日期后将其发送回Azure文件共享的简单流程。我使用的是Azure Storage Connector。



使用流上传根目录下的文件失败,错误如下:
ERROR 2020-07-30 10:44:15,756 [[MuleRuntime].uber.03: [azure_test].azure_testFlow.BLOCKING @7dde3fa] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message : File length must be greater than 0 bytes.
Element : azure_testFlow/processors/6 @ azure_test:azure_test.xml:33 (Upload file in root directory with stream)
Element DSL : <azure-storage:upload-file-in-root-directory-with-stream doc:name="Upload file in root directory with stream" doc:id="93b6bb01-c42c-454a-aaca-3c3325534b5d" config-ref="Azure_Storage_Config" target="payload">
<azure-storage:rootfile fileName="output" fileStream="#[payload]" shareName="dev"></azure-storage:rootfile>
</azure-storage:upload-file-in-root-directory-with-stream>
Error type : MULE:UNKNOWN
FlowStack : at azure_testFlow(azure_testFlow/processors/6 @ azure_test:azure_test.xml:33 (Upload file in root directory with stream))
--------------------------------------------------------------------------------如图所示,有效负载在前两个处理器后面的引号中(不包括记录器)。在转换消息之后,引号消失了,当我单击更新值...它是空的。这是否意味着转换消息后的输出有效负载不再位于流中?如果是这样的话,我怎么才能让转换输出一个流呢?不过,转换后的Logger会在控制台中写入新的有效负载。
编辑:
下面是输入文件:
<data>DATA</data>流的XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:azure-storage="http://www.mulesoft.org/schema/mule/azure-storage"
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/core http://www.mulesoft.org/schema/mule/core/current/mule.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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/azure-storage http://www.mulesoft.org/schema/mule/azure-storage/current/mule-azure-storage.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<azure-storage:config name="Azure_Storage_Config" doc:name="Azure Storage Config" doc:id="ced6e7d8-da1c-4d1e-b02c-fb990de78ed1" >
<azure-storage:sas-token-config-connection accountName="account" sasToken="token"/>
</azure-storage:config>
<flow name="azure_testFlow" doc:id="bcb34135-5d34-4fd8-b794-1a6a668d6f53" >
<azure-storage:download-file-from-root-directory doc:name="Download file from root directory" doc:id="c3893681-5489-4ee0-8058-38b189895a01" config-ref="Azure_Storage_Config">
<azure-storage:root-file fileName="input" shareName="dev" />
</azure-storage:download-file-from-root-directory>
<logger level="INFO" doc:name="Logger" doc:id="183d3636-9ef6-4fb0-b144-c880949dda36" message='#[payload]'/>
<set-payload value="#[payload]" doc:name="Set Payload" doc:id="20769233-90e1-4c5c-9556-b8e582cd638c" mimeType="application/xml" encoding="UTF-8"/>
<logger level="INFO" doc:name="Logger" doc:id="62d02465-952a-4de2-9c9d-a8319f3ddb96" message="#[payload]" />
<ee:transform doc:name="Transform Message" doc:id="04150311-2a96-4215-b252-07a36c3b133e" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml writeDeclaration=false
---
{
data: payload.data ++ now() as String {format: "yyyyMMddHHmm"}
}]]></ee:set-payload>
</ee:message>
<ee:variables >
</ee:variables>
</ee:transform>
<azure-storage:upload-file-in-root-directory-with-stream doc:name="Upload file in root directory with stream" doc:id="9a2f25b6-270f-4cff-bc87-141d7e30147e" config-ref="Azure_Storage_Config">
<azure-storage:rootfile fileName="outputStream" fileStream="#[payload]" shareName="dev" />
</azure-storage:upload-file-in-root-directory-with-stream>
<file:write doc:name="Write" doc:id="f3dc6f68-06aa-4755-b9a6-09cad8224fb7" path="C:\Users\jespe\outputFile" />
<azure-storage:upload-file-in-root-directory doc:name="Upload file in root directory" doc:id="2ccac879-d196-41e1-8a64-58494421ee68" config-ref="Azure_Storage_Config">
<azure-storage:file fileName="outputFile" shareName="dev" path="C:\Users\jespe\outputFile" />
</azure-storage:upload-file-in-root-directory>
<file:delete doc:name="Delete" doc:id="852758e7-94e6-43e2-9421-285f1bb85f26" path="C:\Users\jespe\outputFile" />
</flow>
</mule>在使用流上载文件之前删除了记录器。在转换之后,调试器仍然会显示这样的有效负载。

编辑2:
@jan-h的答案确实是解决方案。不过,在转换消息中设置deferred=true对我不起作用。必须在文件上传流中设置。

发布于 2020-08-05 15:26:19
juast将deferred=true添加到最后一个数据编织。像这样:输出应用程序/xml deferred=true
发布于 2020-07-30 21:25:38
看起来上一次DataWeave转换返回了一个不可重复的流,因此在记录器中使用了它。尝试删除最后一个记录器,查看是否出现有效负载。
如果您共享流的XML会更好。仅仅通过截图是不可能理解它在做什么的。
https://stackoverflow.com/questions/63168640
复制相似问题