0
votes

getting an interesting exception. Using a splitter processor to split a collection using a Collection Splitter. It splits the collection fine but when the flow returns back to the main flow and the flow ends, it throws this exception. Wondering if you'd seen it before :

ERROR 2018-12-07 16:06:26,052 [[ahld_kpi_enabler].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: Caught exception in Exception Strategy: java.lang.UnsupportedOperationException: getPayloadAsBytes(), There has been an attempt to directly access the payload of a message collection, which is unsupported. Please retrieve the value from messageList or use getPayload(DataType.BYTE_ARRAY_DATA_TYPE) java.lang.RuntimeException: java.lang.UnsupportedOperationException: getPayloadAsBytes(), There has been an attempt to directly access the payload of a message collection, which is unsupported. Please retrieve the value from messageList or use getPayload(DataType.BYTE_ARRAY_DATA_TYPE)

The flow is triggered via HTTP and it makes outbound HTTP calls.

There's no aggregation happening of the collection split, its merely used to split the collection and for each object in the collection subsbequent calls / actions are taken

1

1 Answers

1
votes

At the end of your flow when using a collection-splitter, your payload is going to be a Mule message collection and as your using HTTP, it's going to try and serialise that as the HTTP response, which it can't.

So you can either aggregate your payload and then set your payload to something to return or even #[null].

Or you can put your collection-splitter and the logic after that in a separate flow - wrapped in an enricher:

<enricher target="#[flowVars.someVar]">
   <flow-ref name="myCollectionSplitterLogicFlow" />
</enricher>

Or you can just use foreach, which I would personally advise, as splitters are removed in Mule 4.

If you have nested collections, you can have any number of nested foreach :

<foreach collection="#[payload]">
   <foreach collection="#[payload.nestedCollection]">

   </foreach>
</foreach>