How to break into middle of Flow in MULE and return the message to client..?

1.1k views Asked by At

I have a Flow in MULE like below :

<flow name="MetaService">
    <http:inbound-endpoint address="http://localhost:8000/jcore/meta"  
transformer-refs="HttpParams" responseTransformer-refs="JavaObjectToJson">
    </http:inbound-endpoint>

    <component class = "com.java.Meta">
    <component class = "com.java.Meta2"

</flow>

This flow first enters my first component class : "com.java.Meta" . And whatever i "return" from this java class becomes the input for my second component class : "com.java.Meta2".


Now what i want to do is like :

I want to check for something in "payload" in class "Meta" and if it does not exist, then i want to return a Java HashMap to client (in form of JSON) containing the error key.

And if it exist, then i want to return the same "payload" to second component class "Meta2".

How can i achieve this..??

1

There are 1 answers

2
David Dossot On BEST ANSWER

Wrap your second component in a choice router, returning the current message its map payload contains the "error" key.

You can use a Groovy expression:

#[groovy:payload.containsKey('error')]