0
votes

I am aggregating two payloads using the scatter gather in mule. but the problem is sometimes one of the payloads don't contain any values then the aggregation payload looks like:

[{postalCode=7560, addressLine4=-1}, {NullPayload}]

how can i remove the null payload. or how do i set the aggregation to only aggregate when both payloads contain values.

this is my scatter gather:

<scatter-gather doc:name="Scatter-Gather">
        <processor-chain>
            <http:outbound-endpoint exchange-pattern="request-response"
                method="GET"
                address="http://localhost:8080/service/address/postal/#[sessionVars['entityId']]"
                doc:name="HTTP" />
            <data-mapper:transform config-ref="JSON_To_Map_1"
                doc:name="JSON To Map" />
        </processor-chain>
        <processor-chain>
            <http:outbound-endpoint exchange-pattern="request-response"
                method="GET"
                address="http://localhost:8080/service/address/email/#[sessionVars['entityId']]"
                doc:name="HTTP" />
            <data-mapper:transform config-ref="JSON_To_Map"
                doc:name="JSON To Map" />
        </processor-chain>
    </scatter-gather>

so basically its two services that return postal address and email address. but sometimes there is no email address. then the payload must only contain the postal address and no the postal address with a null payload.

1
Could you pls post your full configuration so that soultion can be suggested - Anirban Sen Chowdhary
What to you want the Aggregator to do if one of the payloads is null? - user1760178
Hi there, thanks for the reply. i have added my configurations - Andre Coetzee

1 Answers

1
votes

You haven't post your full configuration so based on your question , the suggesion would be :-

In the setter-getter method, the flow which is generating the null payload .. at the end of that flow you can do the follwing :- Use a choice router and check if payload is null like

<choice doc:name="Choice">
      <when expression="#[message.payload.isEmpty()]">

and if it is null .. then override the null payload by setting your customised payload using set-payload like

<set-payload value="Your customised payload" doc:name="Set Payload"/>