我有一个读取文件的流程,使用 Scatter-Gather 将内容分发到 2 个子流程,并在完成时将文件移动Output/XML
到失败或Failure/XML
失败时移动。
在这两种情况下,表达式:attributes.fileName
失败,因为属性为空。如何将属性设置为持久性?
<flow name="validateFileContent" doc:id="58c241c9-7227-41a8-a67f-5cf4f52bb4bf" >
<file:listener doc:name="Input changed" doc:id="2e6228a7-e153-489a-b6f6-468f67e76475" config-ref="File_Config" directory="Input/XML" watermarkMode="MODIFIED_TIMESTAMP">
<scheduling-strategy >
<fixed-frequency frequency="5" timeUnit="SECONDS" />
</scheduling-strategy>
</file:listener>
<scatter-gather doc:name="Distribute workload" doc:id="15151949-c61d-4629-9fd4-0a4e16d62eec" >
<route >
<flow-ref doc:name="CategoryToType" doc:id="e5d39afa-3b2a-45ef-81c0-afce77a76aef" name="validateCategoryToType" />
</route>
<route >
<flow-ref doc:name="CategoryToSector" doc:id="d3790ba2-b1ac-4511-b748-91adf255344a" name="validateCategoryToSector"/>
</route>
</scatter-gather>
<file:move doc:name="MoveUponSuccess" doc:id="ee659c03-7af5-4a0e-93b0-edb69aefd3ae" sourcePath='#["Input/XML/" ++ attributes.fileName]' targetPath='#["Output/XML/" ++ now() as String{format: "yyyyMMdd_HHmmss"} ++ attributes.fileName]' config-ref="File_Config"/>
<error-handler>
<on-error-propagate enableNotifications="true" logException="true" doc:name="On Error Propagate" doc:id="16001c58-7609-42a6-9bfa-1cd756998f27" >
<logger level="INFO" doc:name="Logger" doc:id="8ec2af18-3e45-4d15-a373-5e9af74723d7" message="#[error]"/>
<file:move doc:name="MoveUponFailure" doc:id="53653598-1d44-4d9a-903c-e82fa61be842" config-ref="File_Config" sourcePath='#["Input/XML/" ++ attributes.fileName]' targetPath='#["Failure/XML/" ++ now() as String{format: "yyyyMMdd_HHmmss"} ++ attributes.fileName]' />
</on-error-propagate>
</error-handler>
</flow>
我尝试设置Metadata
输入/输出属性,但失败了。我可以想象将它放入 var 中,但我认为必须有更好的解决方案。
堆栈跟踪:
消息:“您使用以下参数调用了函数 '++':1:字符串(“输入/XML/”)2:空(空)
但它需要以下组合之一: (Array, Array) (Date, Time) (Date, LocalTime) (Date, TimeZone) (LocalDateTime, TimeZone) (LocalTime, Date) (LocalTime, TimeZone) (Object, Object) (String , String) (Time, Date) (TimeZone, LocalDateTime) (TimeZone, Date) (TimeZone, LocalTime)
1| "输入/XML/" ++ attributes.fileName
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 跟踪:在 + + (line: 1, column: 1) at main (line: 1, column: 14)" 评估表达式:""Input/XML/" ++ attributes.fileName"。错误类型:MULE:EXPRESSION