I have a flow that reads a file, distributes to content to 2 subflows using Scatter-Gather and moves the file upon completion to Output/XML
or to Failure/XML
on failure.
In both scenarios the expression: attributes.fileName
fails because attributes is null. How can I set attributes to be persistent?
<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>
I tried setting Metadata
for input / output attribute, which failed. I could imagine putting it into a var, but I think that there has to be a better solution.
Stacktrace:
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