Using Mule, I need to loop a collection of records in a batch fashion (don't want to use the Batch scope). In the foreach element you have the way to specify the batch size to partition your collection.
Being said that, if you specify a number it works just fine. For instance
<foreach doc:name="For Each" batchSize="100">
<logger message="#[flowVars.counter]" level="INFO" doc:name="Logger"/>
</foreach>
It will print batches of 100 elements as I want. But if I use MEL it throws a NumberFormatException. Here the xml
<foreach doc:name="For Each" batchSize="#[flowVars.counter]">
<logger message="#[flowVars.counter]" level="INFO" doc:name="Logger"/>
</foreach>
The exception
ERROR 2017-03-01 09:47:06,121 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
java.lang.NumberFormatException: For input string: "[flowVars.batchSize]"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_121]
at java.lang.Integer.parseInt(Integer.java:580) ~[?:1.8.0_121]
at java.lang.Integer.valueOf(Integer.java:740) ~[?:1.8.0_121]
at java.lang.Integer.decode(Integer.java:1197) ~[?:1.8.0_121]
I printed the class type of #[flowVars.batchSize] and it is an Integer, so that shouldn't be the problem. Instead, I think that the foreach scope doesn't allow you to use MEL at least for this property.
My question, is it or is it not possible to use MEL to determine the batch size value of a foreach scope?
Thanks in advance.