Reputation: 11
array as an expression in the properties file, :
Myday.contextpath.getUrls [ "http://url1" , "http://url2" , "http://url3" ]
how to use ${Myday.contextpath.getUrls} in a for each scope's collection expression?
Upvotes: 0
Views: 68
Reputation: 40990
Using Mule 4.0, you can use the below syntax to iterate over values stored in property file using for-each
scope
<foreach doc:name="For Each" collection='#[p("Myday.contextpath.getUrls") splitBy ","]'>
<logger doc:name="Logger" level="INFO" message="payload is : #[payload]" />
</foreach>
Note: Assuming that you're storing the properties without array brackets "[" "]" like this:
Myday.contextpath.getUrls = "http://url1,http://url2,http://url3"
Upvotes: 1
Reputation: 91
Hi you can do the following
In your properties file Separate urls with comma or any delimiter
Myday.contextpath.getUrls=http://url1,http://url2,http://url3
then before the foreach component create a payload by splitting the entire property value
via dataweave example p('Myday.contextpath.getUrls') splitBy ","
or via MEL example #['${Myday.contextpath.getUrls}'.split(',')]
then use the payload from step 2 as input payload to your foreach compoment, you may leave the collection field empty
Upvotes: 1