I was following along with the 'Filtering Messages' video in week 6 and noticed a discrepancy. Towards the end of the video, the instructor launches a PostMan request with FOO as the code (http://localhost:8081/flights?code=FOO). In the video he receives a 200 code and an empty list as the returned data. However, when I perform the same thing, I receive an ugly exception message with a code of 500.
I stepped through debugging. The United, American and Delta subflows were all erroring out, which is expected since none have a flight with the destination of FOO. As a result, the output of the Scatter-Gather is a NullPayload, (the exception messages get filtered out because they aren't a List). The issue is the Transform immediately after. When it tries to perform the 'flatten' operation on the NullPayload, it throws an error. Here's what the console says:
ERROR 2017-06-27 14:07:47,628 [[apdev-flights-ws].HTTP_Listener_Configuration.worker.01] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : Exception while executing:
flatten payload
^
Type mismatch for 'flatten' operator
found :null
required :array.
Payload : {NullPayload}
Payload Type : org.mule.transport.NullPayload
Element : /getAllAirlineFlightsFlow/processors/1 @ apdev-flights-ws:implementation.xml:141 (Transform Message)
Element XML :
<dw:set-payload>%dw 1.0%output application/java---flatten payload</dw:set-payload>
</dw:transform-message>
--------------------------------------------------------------------------------
Root Exception stack trace:
com.mulesoft.weave.mule.exception.WeaveExecutionException: Exception while executing:
flatten payload
^
Type mismatch for 'flatten' operator
found :null
required :array.
Can anyone provide some input as to why this doesn't happen in the videos, but is happening to me? Am I not supposed to get a NullPayload?
I've attached my implementation.xml file - saved as a txt since this forum doesn't allow upload of xml extensions
(NOTE: The Scatter-Gather I have does not call the American flow because I'm behind a strict firewall and unable to call out to the external REST service)
corrected-4152-implementation.txt.
It should work.
Please try the attached corrected-4152-implementation.
I think in video by mistake , it was missed ,
it should be :
flatten payload default []
instead of just
flatten payload