使用 Scatter-Gather 后属性验证为 null
attributes validates to null after using Scatter-Gather
我有一个读取文件的流,使用 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,但我认为必须有更好的解决方案。
堆栈跟踪:
Message : "You called the function '++' with these
arguments: 1: String ("Input/XML/") 2: Null (null)
But it expects one of these combinations: (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| "Input/XML/" ++ attributes.fileName
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Trace: at ++ (line: 1, column:
1) at main (line: 1, column: 14)" evaluating expression:
""Input/XML/" ++ attributes.fileName". Error type :
MULE:EXPRESSION
不可以,如果要保留属性,必须将其保存到变量中。无法保证流程中的其他内容不会覆盖它。例如使用任何连接器。
此外,元数据用于设计时,而不是执行时。
我有一个读取文件的流,使用 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,但我认为必须有更好的解决方案。
堆栈跟踪:
Message : "You called the function '++' with these arguments: 1: String ("Input/XML/") 2: Null (null)
But it expects one of these combinations: (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| "Input/XML/" ++ attributes.fileName
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Trace: at ++ (line: 1, column: 1) at main (line: 1, column: 14)" evaluating expression: ""Input/XML/" ++ attributes.fileName". Error type : MULE:EXPRESSION
不可以,如果要保留属性,必须将其保存到变量中。无法保证流程中的其他内容不会覆盖它。例如使用任何连接器。 此外,元数据用于设计时,而不是执行时。