In my flow in Mule 4, I iterate over multiple files to get data from them and transform them to json. I use a parallel ForEach component to do this. Here are the expected outputs from both of these calls:
result 1:
{
"plant": "CD909837289",
"serial": "SRF",
"product": "CMNPSD"
},
{
"plant": "CD909837290",
"serial": "SFG",
"product": "CMNHSA"
}
result 2:
{
"plant": "CD909837296",
"serial": "SFG",
"product": "ERTYUI"
},
{
"plant": "CD909837297",
"serial": "SVH",
"product": "SDFGHJ"
}
When I make the call I get these outputs combined together however, I also get the below message with garbled characters mixed with them:
��srjava.util.ArrayListx����a�IsizexpwsrRorg.mule.runtime.core.internal.message.DefaultMessageBuilder$MessageImplementationeJ蹨��L
inboundMaptLjava/util/Map;LoutboundMapq~LtypedAttributest*Lorg/mule/runtime/api/metadata/TypedValue;xpsr3org.mule.runtime.api.util.CaseInsensitiveMapWrappervrD=wny3LbaseMapq~xpsrjava.util.HashMap���`�F
loadFactorI thresholdxp?@wxsq~sq~?@wxsr(org.mule.runtime.api.metadata.TypedValue�i�Қ,��LdataTypet(Lorg/mule/runtime/api/metadata/DataType;LvaluetLjava/lang/Object;xpsr6org.mule.runtime.core.internal.metadata.SimpleDataType�Jd�~�Z
streamTypeLmimeTypet)Lorg/mule/runtime/api/metadata/MediaType;LtypetLjava/lang/Class;xpsr'org.mule.runtime.api.metadata.MediaTypeͬU�q�S�ZdefinedInAppLparamsq~LprimaryTypetLjava/lang/String;LsubTypeq~xpsrjava.util.Collections$EmptyMapY6�Z���xpt*q~pxvr/org.mule.extension.file.api.LocalFileAttributesJ�5��Z directoryZregularFileJsizeZsymbolicLinkLcreationTimetLjava/time/LocalDateTime;LlastAccessTimeq~LlastModifiedTimeq~xr9org.mule.extension.file.common.api.AbstractFileAttributes���$pLfileNameq~Lpathq~xpsq~tproduct-date.csvt=/Users/dbien_local/Downloads/DATAFORSCORPION/product-date.csvesr
java.time.Ser�]��"H�xpw
��xsq~!w
�*�xsq~!w
��xw��������xz��[
{
"plant": "CD909837289",
"serial": "SRF",
"product": "CMNPSD"
},
{
"plant": "CD909837290",
"serial": "SFG",
"product": "CMNHSA"
}
I get the same message before each result. How can I get rid of the above text and get the expected output only?
EDIT: Below is the XML of the flow:
<file:config name="File_Config" doc:name="File Config" doc:id="45e5b346-2497-4422-961b-a04bb5a7bf80" >
<file:connection workingDir="/Users/dbien_local/Downloads/DATAFORSCORPION" />
</file:config>
<flow name="get-data-ifFlow" doc:id="8d6b11ec-2a24-49b4-82b4-195816aeb8e5" >
<http:listener doc:name="Listener" doc:id="8937d90f-75f7-43d0-bf20-02f70f9b2073" config-ref="HTTP_Listener_config" path="/data"/>
<parallel-foreach doc:name="Parallel For Each" doc:id="50ca63de-9004-4a52-97f8-9935425c2763" collection='#[["date", "product"]]'>
<file:read doc:name="Read" doc:id="f3fbadf3-2716-47c6-803b-90edefff67a3" config-ref="File_Config" path='#["/Users/dbien_local/Downloads/data/product-" ++ payload ++ ".csv"]' />
<ee:transform doc:name="Transform Message" doc:id="cf7d4f97-2144-4a49-958c-323e26b8b00e">
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload map ( payload01 , indexOfPayload01 ) -> {
plant: payload01.plant,
serial: payload01.serial,
product: payload01.product
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</parallel-foreach>
There are only two components in the loop. One reads the data from a csv file and then a transform message component transforms it to JSON. I have absolutely no idea where that java message comes from.
As Aled mentioned, you are seeing the serialized java object. You can add a transform message after parallel-foreach to get the JSON message.
To get the list of payloads, use the following script in a transform message or set payload.
%dw 2.0
output application/json
---
payload.payload